hello all,
i have the below script that we used to backup our DB using oracle's utility called RMAN. This has been working fine, but the issue is when the backup fails and we re-start it, it backups the whole thing again. Example.
lets say i have 5 database on my system(db1,db2,db3,db4,db5) and we use below script which loops for a file called /etc/oratab which has my DB names in it. If the script completes successfully we have no issue. But lets say db1 and db2 backup was successful and db3 backup fails and db4 and db5 backup was good. NOW LETS SAY i want restart by backup as DB3 backup failed...it is going to backup db1, db2, db3,db4,db5 all of them all again and that i was i want to avoid...the script needs to put some flag or something were it knows only db3 has failed and that is the only one that needs to be backed up...
how can i accomplish that? below is the script....
umask o+w
LogMsg()
{
echo "`date '+%Y%m%d.%H%M%S'` :: $*" >> $RMAN_LOG_FILE
}
##########################################################################
# Calls LogMsg and exits with failure
##########################################################################
LogAndFail()
{
LogMsg "$*"
exit 1
}
TODAY=`date '+%C%y_%m_%d_%H_%M'`; export TODAY
export ORATAB=/etc/oratab
###START OF LOOP
for db in `egrep -i ":NBU" $ORATAB | grep -v "^#" | grep -v "\*" | cut -d":" -f1 | sort | uniq`
do
echo "processing database: $db"
export ORACLE_SID=$db
export RMAN_LOG_FILE=/oracle/sqlutils/logs/RMAN_bkp_${ORACLE_SID}_${TODAY}.log
export ORACLE_HOME=`grep -i $ORACLE_SID: ${ORATAB}|grep -v "^#" | cut -f2 -d:`
export PATH=$ORACLE_HOME/bin:$PATH
$ORACLE_HOME/bin/rman <<EOF >> $LOG
connect catalog rman/password@reocverycatalog
connect target /
run
{
allocate channel t1 type disk;
allocate channel t2 type disk;
backup database plus archivelog;
RELEASE CHANNEL t1;
allocate channel for maintenance type disk;
show all;
report obsolete;
delete noprompt expired backup;
delete noprompt obsolete;
crosscheck backup;
crosscheck archivelog all;
release channel;
}
EOF
exit
RSTAT=$?
# ---------------------------------------------------------------------------
# Log the completion of this script.
# ---------------------------------------------------------------------------
if [ "$RSTAT" = "0" ]
then
LOGMSG="Backup successfully $ORACLE_SID"
echo $LOGMSG|mailx -s "BACKUP Status ..." abc@company.com
else
LOGMSG="Backup error $ORACLE_SID"
echo $LOGMSG|mailx -s "BACKUP Status ..." abc@company.com
fi
echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
###### end of loop #######
done
exit $RSTAT