Backups are very important, but they have a shelf life, too. You cannot just keep taking backups and retain all of them forever. You need to decide how long you would like to retain your backups before you can safely remove them in order to make space for more backups. Storage on a disk or tape device is always limited, and you have to come up with some retention policy.
RMAN helps you implement the retention policy for the backups in a very easy, automatic, and efficient way. You can either specify your retention policy in terms of time, or you can define it in terms of number of backup copies. In other words, you can say that you want to retain 30 days of backup, or you can decide that you want to retain 2 copies of backup. In this case, the backups older than 30 days or the oldest third copy of the backup and above will be termed obsolete. You can use the following command to specify the backup retention policy in RMAN in terms of time:
Now after making the preceding persistent configuration, any backups older than 30 days will be considered obsolete. You can use the following command to specify the backup retention policy in RMAN in terms of number f copies:
Now after making the preceding persistent configuration, the oldest third copy of the backup will be considered obsolete. You can also opt to have no retention policy at all in your RMAN configuration by using the following command:
After setting the retention policy, you can run the following command to delete the backups that are obsolete:
You can also use the following command to see which backups are obsolete:
Another term used in RMAN is expired backups. When RMAN is unable to find any backed-up file, it flags that file as expired in its repository. It is important to differentiate between expired and obsolete backups:
- Expired backups are those that are not found by RMAN.
- Obsolete backups are those that are no longer required by RMAN for recovery.