一个典型的增量备份案例,是按照一周为一个周期来进行备份:
|-------|---------|
| 时间 | 备份级别 |
| 星期天晚上 | level 0 |
| 星期一晚上 | level 2 |
| 星期二晚上 | level 2 |
| 星期三晚上 | level 1 |
| 星期四晚上 | level 2 |
| 星期五晚上 | level 2 |
| 星期六晚上 | level 2 |
1、level 0备份脚本
run{
allocate channel d1 device type disk;
backup incremental level 0 database
format '/oracle/rman/lev0_%d_%U'
tag='level0'
channel=d1
include current controlfile;
sql 'alter system archive log current';
backup archivelog all format
'/oracle/rman/lev0_log_%d_%U' delete all input;
release channel d1;
}
2、level 1备份脚本
run{
allocate channel d1 device type disk;
backup incremental level 1 database
format '/oracle/rman/lev1_%d_%U'
tag='level1'
channel = 'd1'
include current controlfile;
sql 'alter system archive log current';
backup archivelog all format
'/oracle/rman/lev1_log_%d_%U' delete all input;
release channel d1;
}
3、level 2备份脚本
run{
allocate channel d1 device type disk;
backup incremental level 2 database
format '/oracle/rman/lev2_%d_%U'
tag='lev2'
channel=d1
include current controlfile;
sql 'alter system archive log current';
backup archivelog all format
'/oracle/rman/lev2_log_%d_%U' delete all input;
release channel d1;
}
这三个备份脚本对应文件lev0.rcv、lev1.rcv、lev2.rcv
采用sh文件来调用这三个级别的备份。三个sh的文件可命名为lev0.sh、lev1. sh、lev2. sh。内容分别为:
rman cmdfile=/oracle/scripts/lev0.rcv log=/oracle/scripts/lev0.log
rman cmdfile=/oracle/scripts/lev1.rcv log=/oracle/scripts/lev1.log
rman cmdfile=/oracle/scripts/lev2.rcv log=/oracle/scripts/lev2.log
采用crontab来制定计划任务
00 23 * * 0 /oracle/backup/lev0.sh
00 23 * * 2 /oracle/backup/l lev2.sh
00 23 * * 2 /oracle/backup/l lev2.sh
00 23 * * 1 /oracle/backup/l lev1.sh
00 23 * * 2 /oracle/backup/l lev2.sh
00 23 * * 2 /oracle/backup/l lev2.sh
00 23 * * 2 /oracle/backup/l lev2.sh