Search

Join this Blog for direct reference of any post into your inbox. To join just click on "Join this Site" under "Follower" then Login with your Email.*** DECLARATION: I Maintain this Blog for Helping Myself While at Work and Welcome any body Needing Help!!!.*** CAUTION: Using any of the script from this Blog may contain at Own Risk. These scripts May or May not have been Tested.***

Wednesday, 1 August 2012

Script: RMAN Hot Backup on Linux Environment

# This script can be used to take a hot backup using RMAN.
# Some of the variables in the initial section of the script need to have valid values
# Set the catalog to the catalog database
# This script will also mail errors encountered in the backup process

# =============================

#!/bin/sh

export ORACLE_SID=...
export ORACLE_HOME=....
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin

DBA="shahid.ahmed@al-sadhan.com"
INST=`hostname`
TODAY=`date +%d%b`
BACKUP_DIR=/u01/backup/
LOG_DIR=/u01/backup/logs
LOGFILE=$LOG_DIR/rman_backup_${ORACLE_SID}_${TODAY}.log
ERRFILE=$LOG_DIR/err_status.log
$ORACLE_HOME/bin/rman <<EOF > ${LOG_DIR}/rman_backup_${ORACLE_SID}_${TODAY}.log
connect target/
connect catalog catalog/catalog@rman
run {
allocate channel t1 TYPE DISK;
setlimit channel t1 kbytes 2048000;
allocate channel t2 TYPE DISK;
setlimit channel t2 kbytes 2048000;
allocate channel t3 TYPE DISK;
setlimit channel t3 kbytes 2048000;
allocate channel t4 TYPE DISK;
setlimit channel t4 kbytes 2048000;
backup full tag BACKUP_FULL_${ORACLE_SID} format '${BACKUP_DIR}/%d_%t_%p_%s_%c_%u.dbf' database;
backup current controlfile format '${BACKUP_DIR}/%d_%t_%p_%s_%c_%u.ctl';
sql 'alter system archive log current';
backup archivelog all format '${BACKUP_DIR}/%d_%t_%p_%s_%c_%u.arc'
archivelog until time 'sysdate-7' delete input;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
}
EOF

egrep "RMAN-|ORA-" $LOGFILE > $ERRFILE
if [ -s $ERRFILE ]; then
mail -s "MTD PROD chfoh-ls-ipr RMAN Backup FAILED $ORACLE_SID" $DBA <
${LOG_DIR}/rman_backup_${ORACLE_SID}_${TODAY}.log
else
mail -s "MTD PROD chfoh-ls-ipr RMAN Backup SUCCESS $ORACLE_SID" $DBA <
${LOG_DIR}/rman_backup_${ORACLE_SID}_${TODAY}.log
fi

1 comments:

  1. Hi Shahid, will it work on Sun Solaris.?

    ReplyDelete