Question : How can one achieve the following while using RMAN to backup the archived logs?
Back up all archived redo logs until specified time and delete them after backing up, and also back up all the other archived redo logs that were not backed up before – all this with a single RMAN command.
Solution
Backup archivelogs older than 10 days and delete them
First let us look at the command to backup all archived logs older than 10 days and delete them:
RMAN> run { allocate channel t1 type disk; backup format '/recover/oracle/%d/arc_%d_%t_%s' archivelog until time 'sysdate-10' delete input; }
The above will back up all archived logs older than 10 days and then delete them.
NOTE : The logs newer than 10 days are not backed up using the above method. To backup them as well use the next method.
Backup all logs and delete logs older than 10 days only
If you would like to back up all archived logs and delete only the ones that are older than 10 days, you can do the following:
RMAN> run { allocate channel t1 type disk; backup format '/recover/oracle/%d/arc_%d_%t_%s' archivelog all archivelog until time 'sysdate-10' delete input; }