RMAN Backup script for Archive log

Backup script for Archive log with RMAN

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


BACKUP ARCHIVELOG FROM SEQUENCE 121 UNTIL SEQUENCE 125;

OR

Script:
RUN {
# backup all archive logs
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
SEND 'NB_ORA_POLICY = $NB_ORA_POLICY, NB_ORA_CLIENT=kilbirnie-ha';
sql 'alter system switch logfile';
BACKUP filesperset 20
FORMAT 'al_%s_%p_%t'
ARCHIVELOG  FROM SEQUENCE 121 UNTIL SEQUENCE 125 DELETE INPUT;
RELEASE CHANNEL ch00;
}

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

Backup archivelog until time 'sysdate-1/24' delete input;

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

RUN {
ALLOCATE CHANNEL ch00 TYPE 'DISK';
SET ARCHIVELOG DESTINATION TO '/archive/OPDBPROD/';
backup ARCHIVELOG FROM SEQUENCE 158941 until sequence 158990 DELETE ALL INPUT;
RELEASE CHANNEL ch00;
}

Note: delete input: is used for delete the archive log from disk.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s