Archivelog Deletion Policy in RMAN Oracle 19c
Quick Tip
When you have a database with Archive Mode enabled or a DataGuard environment you need to take care of the archive logs to maintain enough space on the Fast Recovery Area for the database to be able to work, but at the same time to keep enough archivelogs available in case of a database recovery scenario.
So you need to configure a Deletion Policy and schedule a manual archivelog purge.
According to RMAN documentation if archived logs are in a fast recovery area, then they are automatically deleted when more open disk space is required (~70%).
However you may face issues if you receive a unexpected workload that may fill up the FRA making the database to fail with an ORA-00257: Archiver error, so it’s recommended to execute a scheduled manual deletion.
Deletion Policy for Archive Mode Only
If you have an isolated database but it is in archive mode, you need to:
- Configure RMAN with the following policy:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DEVICE TYPE DISK;
Delete until it has been backed up n times.
- Execute the archivelog deletion at backup time (in this case archivelogs older than 7 days)
including the
delete archivelog
command in your RMAN backup script:
delete nopromt archivelog until time 'sysdate-7';
Following this policy you will receive an error if some archivelog has not been backed up at least twice, even if it’s many days older:
RMAN-08138: warning: archived log not deleted - must create more backups
archived log file name=/oradata/recovery/PATODB/archivelog/2020_07_20/o1_mf_1_8_hlvgk4xo.arc thread=1 sequence=8
Deletion Policy for DataGuard
If you have a DataGuard environment you need to be careful before removing archivelogs as they are the input for the Standby recovery. So you need to:
- Configure RMAN with one of the following options:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
Delete when it has been applied into the Standby.
CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO ALL STANDBY;
Delete when it has been sent to the Standby although it has not been applied.
- Execute the archivelog deletion at backup time in the Primary instance (in this case archivelogs older than 7 days
that had been already backed up twice)
including the
delete archivelog
command in your RMAN backup script:
delete noprompt archivelog until time 'sysdate-7' BACKED UP 2 TIMES TO DEVICE TYPE DISK;
Following this policy you will receive an error if some archivelog has not yet been applied to all the Standby databases even if it’s old and has been already backed up:
RMAN-08120: warning: archived log not deleted, not yet applied by standby
archived log file name=/oradata/recovery/PRMYDB/archivelog/...
or an error if it has not been sent to all the Standby databases:
RMAN-08137: warning: archived log not deleted, needed for standby or upstream capture process
archived log file name=/oradata/recovery/PRMYDB/archivelog/...