RMAN Script to take a Hot Backup of Database using Catalog
RMAN Script to take a Hot Backup of Database using Catalog
# 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=PROD
export ORACLE_HOME=....
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
DBA="himanshu.apps@gmail.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 rman/rman@rmandb
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-3' 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 "PROD RMAN Backup FAILED $ORACLE_SID" $DBA < ${LOG_DIR}/rman_backup_${ORACLE_SID}_${TODAY}.log
else
mail -s "PROD RMAN Backup SUCCESS $ORACLE_SID" $DBA < ${LOG_DIR}/rman_backup_${ORACLE_SID}_${TODAY}.log
fi
Comments
Post a Comment