How can we have different RMAN retention policies for different backups

We cannot have different retention policies for different backups. The retention policy is always the same for all backups. But there could be situations where you would be looking for different kinds of retention policies. Such kind of a situation is explained below.

Example

There are 3 types of backup, daily, weekly and monthly, so we would like to have 3 retention policies 1 for retention of 32 days, 2 for retention of 365 days and other for 700 days for example.

For all your daily backups maintain a normal retention policy i.e.

Rman > configure retention policy for recovery window of 32 days ;

This retention policy is always common for all backups. But since you have to retain the weekly backups for 365 days and monthly backups for 700 days.

Therefore for the weekly and monthly backups, we will be going for the “KEEP” option.

You can exempt a backup from the retention policy by using the KEEP option with the BACKUP command when you create the backup or the KEEP option of the CHANGE command to exempt an existing backup. Note that backups exempted from the retention policy are still fully valid backups, which can be used in restore and recovery operations like any other if RMAN judges them to be the best choice available.

You can change the exempt status of a backup using the CHANGE… KEEP and CHANGE… NOKEEP commands. The NOKEEP option (default) indicates that the backup is not immune from the configured retention policy.

You can specify the LOGS option to save archived logs for a possible incomplete recovery of the long-term backup. When LOGS is specified, all logs more recent than the backup are kept as long as the backup is kept. In other words, KEEP UNTIL TIME… LOGS means that RMAN will keep all logs required to recover the backup as long as the backup is kept. If you specify NOLOGS, then RMAN does not keep the logs required to recover the backup. Note that if you use KEEP UNTIL TIME… with an inconsistent backup, you must use the LOGS option, or that backup will become unusable when the logs required to recover it are deleted as obsolete. In fact, rman does not allow us to take a inconsistent backup with KEEP NOLOGS option.

You can specify an end date using the UNTIL clause, or either specify that the backup should be kept FOREVER. If you specify UNTIL, then RMAN will not mark the backup as obsolete until after the UNTIL date has passed. Note that it is an error to specify KEEP FOREVER with the LOGS option, as this would require keeping all redo logs forever.

Example

For weekly and monthly backups you can take the backups in this way:

RMAN > BACKUP DATABASE KEEP UNTIL TIME "TO_DATE('31-DEC-2007' 'dd-mon-yyyy')" NOLOGS;

OR

RMAN > BACKUP DATABASE KEEP UNTIL TIME 'sysdate +365' NOLOGS;

Specify the until time as needed depending upon whether the backup is weekly or monthly. For the rest of your daily backups you can have the normal retention policy of 32 days.