Thursday, November 26, 2009

RMAN fullbackup - shellscript

#/usr/bin/sh
export ORACLE_SID=db01
export ORACLE_HOME=/home/oracle/product/10.2.0.1
export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin:/home/oracle/product/10.2.0.1/bin:/home/oracle/bin
echo "ORACLE_SID -> ${ORACLE_SID}"
echo "ORACLE_HOME -> ${ORACLE_HOME}"
#-----------------------------------------------
dt=`date +%Y%m%d`
SUBJECT="db01 rmanbackup errors please investigate "
SUBJECTP="db01 backup DONE"
EMAIL_ADDRESS="mail2satheeshmba@gmail.com"
BODY="check the log files and space utilization "
thresold=90
verror=""
outofspace=" The disks is out of space "

#----------------------------------------------
$ORACLE_HOME/bin/rman nocatalog log = /u01/app/oracle/db01/db01/rman_backup_loc/backup_script/db01log$dt<connect target /
configure controlfile autobackup on;
configure device type disk parallelism 4;
configure retention policy to redundancy 7;
configure channel 1 device type disk format '/u01/app/oracle/db01/db01/rman_backup_loc/rman1_%U.bk';
configure channel 2 device type disk format '/u01/app/oracle/db01/db01/rman_backup_loc/rman2_%U.bk';
configure channel 3 device type disk format '/u01/app/oracle/db01/db01/rman_backup_loc/rman3_%U.bk';
configure channel 4 device type disk format '/u01/app/oracle/db01/db01/rman_backup_loc/rman4_%U.bk';
backup database plus archivelog delete all input;
crosscheck backup;
delete noprompt obsolete;
exit

verror= `cat /u01/app/oracle/db01/db01/rman_backup_loc/backup_script/db01log$dt |grep -i error | wc -l`
# the above should be a log file > in crontab
if [ $verror -gt 0 ]; then
echo "$BODY" | mailx -s "$SUBJECT" "$EMAIL_ADDRESS"
echo $verror

fi
exit;

No comments: