假设每5天进行一次备份,第一次是1号,第二次是6号,第三次是11号。
那么请问,REDUNDANCY 1 的情况下,备份脚本有删除过期备份的命令。 这种情况下,在9号时,有一个需求,将DB 使用备份恢复全库至4号? 是否可行?备份文件是否还在。
测试: 如下测试是测试脚本中,先删除历史过期的备份,之后再进行备份的测试,后续根据信息,进行总结。
delete backup; RMAN> list backup; RMAN> show all; using target database control file instead of recovery catalog RMAN configuration parameters for database with db_unique_name TT are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ENCRYPTION FOR DATABASE OFF; # default CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_tt.f'; # default delete noprompt obsolete redundancy 1; RMAN> backup database format '/u01/db_%d_%T_%U'; Starting backup at 24-SEP-20 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/11.2.0.4/app/oracle/tt/users01.dbf input datafile file number=00003 name=/11.2.0.4/app/oracle/tt/undotbs01.dbf input datafile file number=00001 name=/11.2.0.4/app/oracle/tt/system01.dbf input datafile file number=00002 name=/11.2.0.4/app/oracle/tt/sysaux01.dbf input datafile file number=00005 name=/11.2.0.4/app/oracle/tt/example01.dbf input datafile file number=00006 name=/11.2.0.4/app/oracle/tt/test1.dbf input datafile file number=00007 name=/11.2.0.4/app/oracle/tt/test2.dbf input datafile file number=00008 name=/11.2.0.4/app/oracle/tt/cc.dbf channel ORA_DISK_1: starting piece 1 at 24-SEP-20 channel ORA_DISK_1: finished piece 1 at 24-SEP-20 piece handle=/u01/db_TT11204_20200924_41vb8jge_1_1 tag=TAG20200924T231734 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 24-SEP-20 channel ORA_DISK_1: finished piece 1 at 24-SEP-20 piece handle=/u01/db_TT11204_20200924_42vb8jhr_1_1 tag=TAG20200924T231734 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 24-SEP-20 RMAN-08591: WARNING: invalid archived log deletion policy report obsolete; 无记录,因为当前之有一次备份 --delete noprompt obsolete redundancy 1; backup datafile 1 format '/u01/%U.bak'; report obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 1 Report of obsolete backups and copies Type Key Completion Time Filename/Handle -------------------- ------ ------------------ -------------------- Control File Copy 16 08-SEP-19 /11.2.0.4/app/oracle/product/11.2.0/db_1/dbs/snapcf_tt11204.f Backup Set 4 13-MAY-19 Backup Piece 4 13-MAY-19 /home/oracle/work/dg/stdby.ctl Control File Copy 29 17-SEP-19 /u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_tt.f Backup Set 12 24-SEP-20 Backup Piece 12 24-SEP-20 /u01/db_TT11204_20200924_42vb8jhr_1_1 delete noprompt obsolete redundancy 1; 也就是说正常情况下先删除过期的备份 第一次备份后,保留一次备份; 第二次备份后,保留二次备份; 第三次备份呢? 先删除最初的第一次的备份集,保留第二次备份的集合;第三次备份成功后,还是保留2次备份!!! 反过来,先备份,后清理历史备份; 第一次备份,保留一次备份; 第二次备份成功后,将删除第一次备份,还是保留一次备份 第三次同理
根据上述结果: 如果清理历史备份脚本在备份脚本之前,那么在9号的时候,可以使用1号的备份及归档,恢复至4号;
反之则无有效备份,无法回退! 【本篇文档不考虑归档日志备份丢失情况,假设存在】