...
先看一下系统目前的备份策略为何物。
RMAN> SHOW ALL;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/usr/local/oracle/product/10.2.0/phoenix1/dbs/snapcf_orcl.f'; # default
RMAN 在Oracle10g中提供两种备份策略 基于时间的和基于冗余数量的。
基于时间的,就是告诉Oracle 你想恢复到几天前的,除了开天辟地那一刻 你随便填 但你随便一下试试?
如果我设置成7 就是让RMAN保留可以让数据库恢复到一周内任何一天任何时刻下的文件。 设置如下:
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
RMAN> SHOW ALL;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/usr/local/oracle/product/10.2.0/phoenix1/dbs/snapcf_orcl.f'; # default
Okay 策略修改完毕 超出这个时间基准线的备份文件将会被RMAN废弃,可以用DELETE OBSOLETE来清理掉。
另一个 就是默认的那个备份策略就是基于冗余数量的,某个数据文件的冗余备份数量超出了指定数量 RMAN将废弃旧的备份,默认是1 你也可以修改过来。
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
或者更狠!不要策略!
RMAN> CONFIGURE RETENTION POLICY TO NONE;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO NONE;
new RMAN configuration parameters are successfully stored
指定完策略后的工作日里就会有部分的备份被标记为废弃的OBSOLETE的,把他们Report出来!
RMAN> 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
-------------------- ------ ------------------ --------------------
Backup Set 39 29-MAY-12
Backup Piece 39 29-MAY-12 /usr/local/oracle/flash_recovery_area/ORCL/backupset/2012_05_29/o1_mf_nnnd1_TAG20120529T115351_7w8l2j2l_.bkp
Backup Set 40 29-MAY-12
Backup Piece 40 29-MAY-12 /usr/local/oracle/flash_recovery_area/ORCL/autobackup/2012_05_29/o1_mf_s_784554833_7w8l2kdv_.bkp
RMAN> DELETE OBSOLETE;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 39 29-MAY-12
Backup Piece 39 29-MAY-12 /usr/local/oracle/flash_recovery_area/ORCL/backupset/2012_05_29/o1_mf_nnnd1_TAG20120529T115351_7w8l2j2l_.bkp
Backup Set 40 29-MAY-12
Backup Piece 40 29-MAY-12 /usr/local/oracle/flash_recovery_area/ORCL/autobackup/2012_05_29/o1_mf_s_784554833_7w8l2kdv_.bkp
Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=/usr/local/oracle/flash_recovery_area/ORCL/backupset/2012_05_29/o1_mf_nnnd1_TAG20120529T115351_7w8l2j2l_.bkp recid=39 stamp=784554832
deleted backup piece
backup piece handle=/usr/local/oracle/flash_recovery_area/ORCL/autobackup/2012_05_29/o1_mf_s_784554833_7w8l2kdv_.bkp recid=40 stamp=784554833
Deleted 2 objects
补:无效的备份有两种。手工删除的被标记为EXPIRED,超出备份策略的被标记为OBSOLETE。