RMAN Retention Policy governs how long backup files are needed for recovery, and the database manages the storage used for backups. Files no longer needed are eligible for deletion when RMAN needs to reclaim space for new files.
Use the CONFIGURE RETENTION POLICY command to specify the RMAN retention policy. Some common operation are listed below.
- Recovery window-Based RMAN Retention Policy
- Redundancy-Based RMAN Retention Policy
- Disable RMAN Retention Policy
- Delete Obsolete backup behind RMAN Retention policy
- Override RMAN Retention Policy
Recovery window-Based RMAN Retention Policy
RMAN will retain as many full or level 0 incremental backups as necessary. For example, with a Recovery Window of seven days, RMAN will maintain enough image copies, incremental backups, and archived redo logs to ensure that the database can be restored and recovered to any point in time within the last seven days. Any backups that are not needed to support this recovery window are marked as OBSOLETE and are automatically removed by RMAN if a flash recovery area is used and disk space is needed for new backups.
Retention policy to a recovery window of four days
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 4 DAYS;
Redundancy-Based RMAN Retention Policy
Redundancy retention policy directs RMAN to retain the specified number of full or level 0 backups or copies of each datafile and control file. Any extra copies or backups beyond the number specified in the redundancy policy are marked as OBSOLETE. Obsolete backups are automatically removed if disk space is needed and a flash recovery area is used. Otherwise, you can use the delete obsolete command to remove the backup files and update the catalog. The default retention policy is REDUNDANCY 1.
RMAN retains all archived logs and incremental backups that are needed to recover the nonobsolete backups.
If the retention policy is set to NONE, no backups or copies are ever considered obsolete, and the DBA must manually remove unneeded backups from the catalog and from disk.
Retention policy to retains three backups of each datafile
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3;
Disable RMAN Retention Policy
When you disable the retention policy, RMAN does not consider any backup as obsolete. To disable the retention policy, run this command:
CONFIGURE RETENTION POLICY TO NONE;
Delete Obsolete backup behind RMAN Retention policy
Delete old backups no longer required by the retention policy.
RMAN> DELETE OBSOLETE;
If flash recovery is set no need to perform this step. The DB automatically delete obsolete backups when space is needed.
Override RMAN Retentation Policy
you can use BACKUP.. KEEP or CHANGE.. KEEP option of the backup and change command to override the retentation policy for individual backups.