Rman+crontab实现一周自动备份计划

Rman+crontab实现一周自动备份计划
要点:
1、编写脚本,在脚本中列出环境变量,脚本文件bakl0.sh内容如下:(这是关键的一步必须要在调用脚时给出环境变量)
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/10g
export ORACLE_SID=kboa
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
/oracle/10g/bin/rman target / msglog=/backup/bakl0.log cmdfile=/backup/bakl0

注解:/oracle/10g/bin/rman为rman的绝对路径,cmdfile是rman的备份脚本

2、rman的执行脚本,0级备份用的脚本bakl0内容如下:(其它级别的备份脚本雷同)
run {
allocate channel c1 type disk;
backup
incremental level 0
format "/backup/autobackup/inc0_%I_%t"
tag monday_inc0
database plus archivelog delete input;
backup current controlfile;
release channel c1;
}
3、设定crontab定期执行备份
crontab -e -u oracle
45 23 * * 0 /oracle/10g/bin/rman target / msglog=/backup/bakl0.log cmdfile=/backup/bakl0
45 23 * * 1 /oracle/10g/bin/rman target / msglog=/backup/bakl2.log cmdfile=/backup/bakl2
45 23 * * 2 /oracle/10g/bin/rman target / msglog=/backup/bakl2.log cmdfile=/backup/bakl2
45 23 * * 3 /oracle/10g/bin/rman target / msglog=/backup/bakl1.log cmdfile=/backup/bakl1
45 23 * * 4 /oracle/10g/bin/rman target / msglog=/backup/bakl2.log cmdfile=/backup/bakl2
45 23 * * 5 /oracle/10g/bin/rman target / msglog=/backup/bakl2.log cmdfile=/backup/bakl2
45 23 * * 6 /oracle/10g/bin/rman target / msglog=/backup/bakl2.log cmdfile=/backup/bakl2
 

你可能感兴趣的:(crontab,职场,rman,休闲)