rman增量备份与恢复
1.备注全备和增量备的时候需要加cumulative 参数
不加这个参数,需要全量以来的归档日志,那增量就没意义了,建议把归档保留时间长一些
2.全量备份和增量备份把plus archivelog 也加上或者单独用脚本把归档进行备份。
!/bin/bash
source /home/oracle/.bash_profile
backtime=$(date +"20%y%m%d%H%M%S")
rman target / log=/arch/rman_bak/level0_backup_mycim4_$backtime.log<<-EOF
run {
set limit channel d1 kbytes 1800000; ## 限制备份集大小2GB,有些操作系统限制文件不能超过2GB,否则报错ORA-19502
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
backup as compressed backupset
incremental level 0
filesperset 5
tag='RMAN_backup_level_0'
format '/arch/rman_bak/DB_level0_%d_%T_%U.bak'
database;
sql 'alter system archive log current'; ## ADG备库无法执行该操作
backup as compressed backupset
filesperset 20
tag='Archivelog_backup'
format '/arch/rman_bak/arc_%d_%s_%p_%u_%T.bak'
archivelog all;
delete noprompt archivelog all completed before 'sysdate-7';
release channel d1;
release channel d2;
release channel d3;
release channel d4;
crosscheck backup;
delete noprompt expired backup device type disk;
delete noprompt obsolete recovery window of 7 days device type disk;
delete noprompt obsolete redundancy 1 device type disk;
delete noprompt backup of archivelog until time='sysdate-7' device type disk;
backup current controlfile format='/arch/rman_bak/ctl_%s_%p_%t' tag='backup_contorlfile';
backup spfile format='/arch/rman_bak/spfile_%s_%p_%t' tag='backup_spfile';
}
exit;
EOF
!/bin/bash
source /home/oracle/.bash_profile
backtime=$(date +"20%y%m%d%H%M%S")
rman target / log=/arch/rman_bak/level1_backup_mycim4_$backtime.log<<-EOF
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
set limit channel d1 kbytes 1800000; ## 限制备份集大小2GB,有些操作系统限制文件不能超过2GB,否则报错ORA-19502
backup as compressed backupset
incremental level 1
filesperset 5
tag='RMAN_backup_level_1'
format '/arch/rman_bak/DB_level1_%d_%T_%U.bak'
database;
sql 'alter system archive log current';
backup as compressed backupset
filesperset 50
tag='Archivelog_backup'
format '/arch/rman_bak/arc_%d_%s_%p_%u_%T.bak'
archivelog all;
delete noprompt archivelog all completed before 'sysdate-7';
release channel d1;
release channel d2;
release channel d3;
release channel d4;
crosscheck backup;
delete noprompt expired backup device type disk;
delete noprompt obsolete recovery window of 7 days device type disk;
delete noprompt obsolete redundancy 1 device type disk;
delete noprompt backup of archivelog until time='sysdate-7' device type disk;
backup current controlfile format='/arch/rman_bak/ctl_%s_%p_%t' tag='backup_contorlfile';
}
exit;
EOF
RMAN> CROSSCHECK BACKUP;
RMAN> CROSSCHECK ARCHIVELOG ALL;
-- 删除过期的记录
RMAN> DELETE EXPIRED BACKUP;
RMAN> DELETE EXPIRED ARCHIVELOG ALL;
-- 根据保留策略删除过时的物理文件
RMAN> DELETE OBSOLETE;

浙公网安备 33010602011771号