RMAN: Delete older archivelogs to free space

A development database with a small FRA was filling it up with archived logs, hanging the database on log file switch (needs archiving).

The best way to clear out old, unneeded archived logs is of course to get RMAN to do it for me. For this dev db, there’s no catalog database – it’s using controlfile as recovery catalog. A quick investigation showed that it had been set up with the default config of a 7 day recovery window but didn’t have the space for it:

RMAN> connect target
connected to target database: MYDB (DBID=xxxxxxxx)
 
RMAN> show retention policy;
RMAN configuration parameters for database with db_unique_name MYDB are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;

There was also no archivelog deletion policy, so the old archivelogs were just hanging around forever.

There’s no critical data in this database, but I want to run it in archivelog mode, so I used the following RMAN commands to change the recovery window and get rid of the older archived logs:

CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
CONFIGURE RMAN OUTPUT TO KEEP FOR 1 DAYS;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;
delete obsolete recovery window of 1 days;
DELETE ARCHIVELOG ALL backed up 1 times to disk;

“delete obsolete”: This gets rid of any files we don’t need for recovery window of 1 day. Burleson Consulting has a good quick primer on “delete obsolete” here.

“delete archivelog all backed up 1 times to disk”: this is deleting all the archive logs that have already been backed up. This is necessary because I didn’t have any archivelog deletion policy in place, so even after being backed up the archived logs were sticking around.

Further reading: I like this primer on managing archivelogs using RMAN by Guy Lambregts, and this article on RMAN delete obsolete by Ramesh Natarajan (@thegeekstuff).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.