Oracle RMAN: Backup Archive Logs Effectively

Backup the Archive log files with RMAN in Oracle

RMAN is backup tool provided by oracle to take physical backup. It is most powerfully tool in oracle for backup and recovery scenarios.
Archive log is generated by database for full recovery of database. when is enabled then you are only able to take the hot/online backup of oracle database.

Check the status of archive log

Connect with sqlplus / as sysdba

SQL>archive log list;

Enable the archive log mode

1. Shutdown the database
Shutdown immediate;

2. start the database in mount state
Start mount;

3. Set the location
alter system set log_archive_dest_1='LOCATION=/arch' scope = both;

4. Bring database in archive mode
Alter database archivelog;

5. Open the database
alter database open;

Backup archive for specific sequence number

-- Single archive log
RMAN> backup archivelog sequence <seq_number>;

-- specify the range of sequence for backup
backup format '/backup/%d_%s_%p_%t.arc.bkp'
      archivelog from sequence 1000 until sequence 1050;

Backup Archive log for specific time and delete archive log after backup

-- Backup Archive Logs Until a Specific Time
RMAN> backup archivelog until time "to_date('2025-01-20 10:00','YYYY-MM-DD HH24:MI')" delete input;

-- Backup Archive Logs Older Than X Hours (Common Use Case)
RMAN> backup archivelog until time "sysdate - (2/24)" delete input;

-- Backup Archive Logs Between Two Times
RMAN> backup archivelog from time "to_date('2025-01-20 08:00','YYYY-MM-DD HH24:MI')" until time "to_date('2025-01-20 10:00','YYYY-MM-DD HH24:MI')" delete input;

Note: delete input is used for delete the archive log from disk after backup complete

Set or Change archive log location in RMAN backup Script

set the destination of archive log manually in script with SET archive log destination to ‘location’.

run {
    set archivelog destination '/new/archive/location';
    backup archivelog all delete input;
}

Note: delete input is used for delete the archive log from disk after backup complete

Leave a Reply