码迷,mamicode.com
首页 > 数据库 > 详细

oracle 备份脚步

时间:2016-11-02 14:06:54      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:div   class   ack   upd   time   dir   version   $nf   app   

 1 #!/bin/sh
 2 # Date: 2016-08-13 15:34
 3 # Author: chzh
 4 # Version: 0.0.1
 5 # Update: Add copy db backup file to remote back server
 6 
 7 export ORACLE_BASE=/u01/app/oracle
 8 export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
 9 export PATH=$ORACLE_HOME/bin:$PATH
10 export ORACLE_OWNER=oracle
11 export ORACLE_SID=orcl
12 export NLS_LANG=American_America.ZHS16GBK
13 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
14 
15 cd /home/oracle/db_backup_188
16 exptime=`date +%Y-%m-%d_%H`
17 nfs_mount_dir=`df -h | grep -i 211.153.66.111 | awk {print $6}`
18 [ -n $nfs_mount_dir ] && remote_back_dir=${nfs_mount_dir}/db_backup_oracle_6.174
19 
20 echo "backup the log file"
21 [ -d script_execute_log ] || mkdir script_execute_log
22 mv exp.log script_execute_log/exp_`date +%Y-%m-%d`.log
23 
24 cat exp.list | while read dbUser dbPasswd
25 do
26         echo $dbUser
27         exp $dbUser/$dbPasswd GRANTS=Y file=$dbUser"_"$exptime.dmp
28         if [ "0" == $? ]
29         then
30                 tar -zcvf $dbUser"_"$exptime.dmp.tar.gz $dbUser"_"$exptime.dmp
31         [ -d ${remote_back_dir}/`date +%Y-%m` ] || mkdir ${remote_back_dir}/`date +%Y-%m`
32         /bin/cp $dbUser"_"$exptime.dmp.tar.gz ${remote_back_dir}/`date +%Y-%m`
33                 rm $dbUser"_"$exptime.dmp
34         fi
35 done
36 
37 # 10 mean 3 day ago, Because have to user exported tables.
38 if [ `ls -l *.tar.gz | wc -l` -gt 6 ]; then
39     find . -mtime +2 -name "*.dmp.tar.gz" |xargs /bin/rm -f > /dev/null
40 fi

同目录下exp.list文件存放帐户名和密码。

 

oracle 备份脚步

标签:div   class   ack   upd   time   dir   version   $nf   app   

原文地址:http://www.cnblogs.com/yangliheng/p/6022458.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!