ITPub博客

首页 > 数据库 > Oracle > Oracle expdp 脚本

Oracle expdp 脚本

原创 Oracle 作者:fjzcau 时间:2015-12-22 15:36:53 0 删除 编辑

  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博客 ” ,链接:https://blog.itpub.net/22661144/viewspace-1876876/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-04-03

  • 博文量
    208
  • 访问量
    547155