Oracle expdp 指令碼

fjzcau發表於2015-12-22

  1. [oracle@yhbd08 scripts]$ crontab -l |tail -3
  2. #每天expdp備份資料庫,Add by fjzcau 2015-12-22
  3. 10 15 * * * /yohodata/fjzcau/scripts/yhbd08_orcl_expdp.sh > /dev/null 2>&1

  1. #---------------------------------------------------------------------------#
  2. # Scripts : /yohodata/fjzcau/scripts/yhbd08_orcl_expdp.sh
  3. # Author : fangjz/
  4. # Date : 2015/12/22
  5. # Purpose : Expdp Oracle data
  6. # Notes : This script can be run in crontab or in other shell script.
  7. # Parameters :
  8. #---------------------------------------------------------------------------#

  9. # Oracle Env
  10. if [ -f /home/oracle/.bash_profile ]
  11. then
  12.    . /home/oracle/.bash_profile
  13. fi

  14. bakdate=`date '+%Y%m%d%H'`
  15. cd /yohodata/expdp_orcl

  16. i_pre="`hostname`_orcl"

  17. log=${i_pre}_${bakdate}.log

  18. file1=${i_pre}_${bakdate}_expdp_01.dmp
  19. file2=${i_pre}_${bakdate}_expdp_02.dmp
  20. file3=${i_pre}_${bakdate}_expdp_03.dmp
  21. file4=${i_pre}_${bakdate}_expdp_04.dmp

  22. expdp system/Yoho_bi123 directory=expdp_orcl parallel=4 full=y \
  23. dumpfile=$file1,$file2,$file3,$file4 logfile=$log

  24. #version=10

  25. nohup gzip $file1 &
  26. nohup gzip $file2 &
  27. nohup gzip $file3 &
  28. nohup gzip $file4 &

  29. sleep 5

  30. now_time=`date +"%Y%m%d %H:%M:%S"`
  31. echo "-->$now_time gzip ${i_pre} start ..." >> $log

  32. i_cnt=0
  33. while [ 1 = 1 ]
  34. do
  35.   i_gzip_count=`ps -ef | grep gzip | grep -v grep | grep ${i_pre}_${bakdate}_expdp |wc -l`

  36.   if [ ${i_gzip_count} -eq 0 ]
  37.   then
  38.     now_time=`date +"%Y%m%d %H:%M:%S"`
  39.     echo "-->$now_time gzip ${i_pre} ok!" >> $log
  40.     break
  41.   fi
  42.   i_cnt=`expr $i_cnt + 1`
  43.   echo " ${i_cnt}:${i_gzip_count} gzip process running,sleep 60 seconds..." >> $log
  44.   sleep 60
  45. done

  46. now_time=`date +"%Y%m%d %H:%M:%S"`
  47. echo "-->$now_time gzip ${i_pre} end ." >> $log

  48. #ftp -i -n 123.57.245.98 <<!
  49. #user u1 u1
  50. #bin
  51. #put $file1.gz
  52. #put $log
  53. #put $0
  54. #by
  55. #!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22661144/viewspace-1876876/,如需轉載,請註明出處,否則將追究法律責任。

相關文章