0级备(0级备是增量备的基础,内容和全备相同)
vi rman_bak0.sh
crosscheck archivelog all;
run{
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/home/oracle/controlfile-%F.bkp';
allocate channel cha1 type disk;
backup
incremental level 0
format '/home/oracle/%d_inc0_%u_%T.bkp'(u表示唯一的ID,大T是日期,小t是时间)
tag monday_inc0
database;
release channel cha1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
1级备
vi rman_bak1.sh
run{
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/home/oracle/controlfile-%F.bkp';
allocate channel cha1 type disk;
backup
incremental level 1
format '/home/oracle/%d_inc1_%u_%T.bkp'(u表示唯一的ID,大T是日期,小t是时间)
tag inc1
database;
release channel cha1;
}
2级备
vi rman_bak2.sh
crosscheck archivelog all;
run{
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/home/oracle/controlfile-%F.bkp';
allocate channel cha1 type disk;
backup
incremental level 2
format '/home/oracle/%d_inc2_%u_%T.bkp'(u表示唯一的ID,大T是日期,小t是时间)
tag inc2
database;
release channel cha1;
}
自动备份
crontab -e -u oracle(命令的意思是编辑oracle用户的定时执行(-e,edit -u oracle,oracle用户))
分 时 日 月 星期(0代表星期天)
45 23 * * 0 rman target / msglog=bakl0.log cmdfile=/home/oracle/rman_bak0.sh(星期天的23:45会以oracle用户的身份来执行命令)
45 23 * * 1 rman target / msglog=bakl2.log cmdfile=/home/oracle/rman_bak2.sh
45 23 * * 2 rman target / msglog=bakl2.log cmdfile=/home/oracle/rman_bak2.sh
45 23 * * 3 rman target / msglog=bakl1.log cmdfile=/home/oracle/rman_bak1.sh
45 23 * * 4 rman target / msglog=bakl2.log cmdfile=/home/oracle/rman_bak2.sh
45 23 * * 5 rman target / msglog=bakl2.log cmdfile=/home/oracle/rman_bak2.sh
45 23 * * 6 rman target / msglog=bakl2.log cmdfile=/home/oracle/rman_bak2.sh
然后启动crontab ,启动crontab的命令:
root> service crond restart
root> chkconfig crond on
本文参考David Dai'sblog,原文地址:http://blog.csdn.net/tianlesoftware/archive/2009/10/19/4699320.aspx
[@more@]来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24586480/viewspace-1049472/ ,如需转载,请注明出处,否则将追究法律责任。