The RMAN retention policy specifies how many copies of backup we need to retain, By default, the value is 1.
Setting this parameter to 2 ensures that the latest two copies of datafile or tablespace backups is retained.
Check the retention policy of database
RMAN> show retention policy;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name TESTDB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
Take the backup of tablespace or database twice. In this case we will take tablespace backup
RMAN> backup tablespace users;
Starting backup at 22-OCT-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK
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=+DATA/testdb/datafile/users.259.892594189
channel ORA_DISK_1: starting piece 1 at 22-OCT-15
channel ORA_DISK_1: finished piece 1 at 22-OCT-15
piece handle=/u01/app/backup/TESTDB_69_%1.bak tag=TAG20151022T230309 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 22-OCT-15
RMAN> backup tablespace users;
Starting backup at 22-OCT-15
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=+DATA/testdb/datafile/users.259.892594189
channel ORA_DISK_1: starting piece 1 at 22-OCT-15
channel ORA_DISK_1: finished piece 1 at 22-OCT-15
piece handle=/u01/app/backup/TESTDB_70_%1.bak tag=TAG20151022T230337 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-15
Check whether we have obsolete backups
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 67 22-OCT-15
Backup Piece 67 22-OCT-15 /u01/app/backup/TESTDB_69_%1.bak
Delete the backup that does not satisfy retention policy:-
RMAN> delete noprompt 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 67 22-OCT-15
Backup Piece 67 22-OCT-15 /u01/app/backup/TESTDB_69_%1.bak
deleted backup piece
backup piece handle=/u01/app/backup/TESTDB_69_%1.bak RECID=67 STAMP=893804592
Deleted 1 objects
RMAN>
Setting this parameter to 2 ensures that the latest two copies of datafile or tablespace backups is retained.
Check the retention policy of database
RMAN> show retention policy;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name TESTDB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
Take the backup of tablespace or database twice. In this case we will take tablespace backup
RMAN> backup tablespace users;
Starting backup at 22-OCT-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK
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=+DATA/testdb/datafile/users.259.892594189
channel ORA_DISK_1: starting piece 1 at 22-OCT-15
channel ORA_DISK_1: finished piece 1 at 22-OCT-15
piece handle=/u01/app/backup/TESTDB_69_%1.bak tag=TAG20151022T230309 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 22-OCT-15
RMAN> backup tablespace users;
Starting backup at 22-OCT-15
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=+DATA/testdb/datafile/users.259.892594189
channel ORA_DISK_1: starting piece 1 at 22-OCT-15
channel ORA_DISK_1: finished piece 1 at 22-OCT-15
piece handle=/u01/app/backup/TESTDB_70_%1.bak tag=TAG20151022T230337 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-15
Check whether we have obsolete backups
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 67 22-OCT-15
Backup Piece 67 22-OCT-15 /u01/app/backup/TESTDB_69_%1.bak
Delete the backup that does not satisfy retention policy:-
RMAN> delete noprompt 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 67 22-OCT-15
Backup Piece 67 22-OCT-15 /u01/app/backup/TESTDB_69_%1.bak
deleted backup piece
backup piece handle=/u01/app/backup/TESTDB_69_%1.bak RECID=67 STAMP=893804592
Deleted 1 objects
RMAN>
No comments:
Post a Comment