Solved

Adding Logfile to RMAN Email function

Posted on 2009-04-13
2
1,734 Views
Last Modified: 2013-12-18
Listed below you will find my RMAN Shell script. I need to add the logfile results of this RMAN script to the email function whether it succeeds or fails. Any simple recommendations?


#!/bin/ksh
#----------------------------------------------
export ORACLE_HOME=/opt/u01/app/oracle/product/10.2.0/db_1
export ORACLE_SID=act1g
export PATH=$PATH:$ORACLE_HOME/bin
#----------------------------------------------
MAIL_LIST="jdoe@act1g.com"
#----------------------------------------------
rman nocatalog <<EOF
connect target sys/0racle10g@act1g
run {allocate channel oem_backup_disk1 type disk format '/opt/u08/orabkup/rman/full_bkup/act1g/full_bkp_%d_set%s_piece%p_%T
_%U';
BACKUP FULL
DATABASE PLUS ARCHIVELOG;
backup current controlfile format '/opt/u08/orabkup/rman/full_bkup/act1g/ctl_bkp_%s_%p';
backup spfile format '/opt/u08/orabkup/rman/full_bkup/act1g/sp_bkp_%s_%p';
crosscheck backup;
DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 14 DAYS;
release channel oem_backup_disk1;
}
EOF
#
if [ $? -ne 0 ]; then
SUBJ="act1g RMAN Backup Failed"
TO=jdoe@act1g.com
(
cat << !
To : ${TO}
Subject : ${SUBJ}
Cc : ${CC}
!
cat << !
act1g Full RMAN Backup Failed. Please check backups.
!
#uuencode ${1} ${1}
!
) | /usr/lib/sendmail -v ${TO} ${CC}
EOF
#
else
SUBJ="act1g RMAN Backup Completed Successful"
TO=jdoe@act1g.com
(
cat << !
To : ${TO}
Subject : ${SUBJ}
Cc : ${CC}
!
cat << !
act1g Full RMAN Backup Completed Successfully.
!
#uuencode ${1} ${1}
!
) | /usr/lib/sendmail -v ${TO} ${CC}
fi
#----------------------------------------------
date
#----------------------------------------------
0
Comment
Question by:Omega002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Richard Olutola earned 250 total points
ID: 24135616
 You need to define RMANLOG variables to point to your a designated location on server.

  R.

# Check status of RMAN backup and email status
RMAN_EXIT=$?
#
case $RMAN_EXIT in
0)mail -s "SUCCESS" $MAIL_LIST<$RMANLOG
   ;;
*)mail -s "FAILURE with exit code: $RMAN_EXIT" $MAIL_LIST<$RMANLOG
  exit 1
   ;;
esac

Open in new window

0
 
LVL 4

Assisted Solution

by:dkaisla
dkaisla earned 250 total points
ID: 24145250
The way I do it, I put the rman script in another file then call it through the shell script. Here's my approach assuming your scripts are located in $SCRIPTS.

#!/bin/ksh
#----------------------------------------------
export ORACLE_HOME=/opt/u01/app/oracle/product/10.2.0/db_1
export ORACLE_SID=act1g
export PATH=$PATH:$ORACLE_HOME/bin
 
#### <added by dkaisla>
working_dir=/opt/u08/orabkup/rman/full_bkup/act1g/
SCRIPTS=/opt/u08/orabkup/rman/full_bkup/act1g/
export SCRIPTS 
BDATE=`date +%m%d%y`
LOG=$SCRIPTS/logs/$ORACLE_SID'_'$BDATE.log
 
cd $working_dir
#### </dkaisla>
 
#----------------------------------------------
MAIL_LIST="jdoe@act1g.com"
#----------------------------------------------
 
#### <added by dkaisla>
date|tee $LOG
rman target sys/0racle10g@act1g @$SCRIPTS/$ORACLE_SID'_Bkup.rman' |tee -a $LOG
date|tee -a $LOG
 
x=`grep -c 'RMAN-' $LOG`
if [ $x -eq 0 ]
then
	echo "BACKUP SUCCESSFUL"|tee -a $LOG
	mailx -s "BACKUP SUCCESSFUL" $MAIL_LIST <$LOG
else
	echo " "|tee -a $LOG
	echo " "|tee -a $LOG
	echo "ERROR(S) ENCOUNTERED DURING BACKUP"|tee -a $LOG
	echo " "|tee -a $LOG
	echo "BACKUP FAILED"|tee -a $LOG
	mailx -s "BACKUP FAILED" $MAIL_LIST <$LOG
fi
done
exit
#### </dkaisla>
 
#
#if [ $? -ne 0 ]; then
#SUBJ="act1g RMAN Backup Failed"
#TO=jdoe@act1g.com
#(
#cat << !
#To : ${TO}
#Subject : ${SUBJ}
#Cc : ${CC}
#!
#cat << !
#act1g Full RMAN Backup Failed. Please check backups.
#!
#uuencode ${1} ${1}
#!
#) | /usr/lib/sendmail -v ${TO} ${CC}
#EOF
#
#else
#SUBJ="act1g RMAN Backup Completed Successful"
#TO=jdoe@act1g.com
#(
#cat << !
#To : ${TO}
#Subject : ${SUBJ}
#Cc : ${CC}
#!
#cat << !
#act1g Full RMAN Backup Completed Successfully.
#!
##uuencode ${1} ${1}
#!
#) | /usr/lib/sendmail -v ${TO} ${CC}
#fi
#----------------------------------------------
#date
#----------------------------------------------

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Salesforce.com is a cloud-based customer relationship management (CRM) system. In this article, you will learn how to add and map custom lead and contact fields to your Salesforce instance.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question