How to send an email once a EXP has been taken ... [message #176461] |
Thu, 08 June 2006 06:47 |
frank.svs
Messages: 162 Registered: February 2006
|
Senior Member |
|
|
Hi Team,
I've written a Daily backup script which is batch file.
This takes the logical bkp and places all the backup dump files in the directory path "D:\BACKUPs". The Database is running on Windows 2003 Server Platform.
I looks like this .
bkp.bat
------
d:
cd backups
set Today=%DATE:~-10%
set Month=%Today:~0,2%
set Day=%Today:~3,2%
set Year=%Date:~10,4%
set hh=%TIME:~0,2%
set mi=%TIME:~3,2%
set dirname=%Year%_%Month%_%Day%
set expfile=%Year%_%Month%_%Day%_%hh%%mi%.dmp
set logfile=%Year%_%Month%_%Day%_%hh%%mi%.log
d:
cd backups
md %dirname%
cd %dirname%
exp userid=uname/pwd@servicename FILE=%expfile% LOG=%logfile% CONSISTENT=Y
All that i want is that, is there any cmd to send an email once the backup is taken . I should be able to write it within this script itself. If anyone knows.Please help me out.
Thanks in Advance.
|
|
|
|
Re: How to send an email once a EXP has been taken ... [message #176609 is a reply to message #176461] |
Thu, 08 June 2006 21:37 |
hmatijaca
Messages: 2 Registered: April 2005
|
Junior Member |
|
|
on unix I use this and works
#!/bin/ksh
#
# Oracle database backup script
#
. ~oracle/.profile
DB_INSTANCE=$1
if [[ -z ${DB_INSTANCE} ]]; then
echo "Usage $0 <DB_instance_name>"
exit 1
fi
ORAID=backup/backup
MAIL=test@email.com
CCMAIL=test@eamil.com
HOST=`hostname`
SUBJECT="Database <${DB_INSTANCE}> backup report"
ORA_SERVER=`ps -fu ${LOGNAME} -o comm | /usr/xpg4/bin/grep -x "ora_\(.*\)_${DB_I
NSTANCE}" | grep -v "grep"| wc -l`
if [[ ${ORA_SERVER} -eq 0 ]]; then
SUBJECT="No Oracle <${DB_INSTANCE}> instance is running on $HOST"
cat /dev/null | /usr/bin/mail -s "${SUBJECT}" -c ${CCMAIL} ${MAIL}
exit 1
fi
case ${DB_INSTANCE} in
NAME )
esac
Exp_dir=/mydirectory
Full_exp_file=${Exp_dir}/exp_full_${DB_INSTANCE}.dmp
Exp_file=${Exp_dir}/exp_full_${DB_INSTANCE}.dmp
Exp_log_file=${Exp_dir}/exp_full_${DB_INSTANCE}.log
Pipe_name=/tmp/pipe_exp_full_${DB_INSTANCE}
if [[ -a ${Pipe_name} ]]; then
echo "Pipe file ${Pipe_name} already exists !"
fi
$ORACLE_HOME/bin/exp ${ORAID} full=y statistics=none direct=y compress=n file=$
{Full_exp_file} log=${Exp_log_file} >>/dev/null 2>&1
echo "Finished export by "`date`>> ${Exp_log_file} 2>&1
cat ${Exp_log_file} | mailx -s "${SUBJECT}" -c ${CCMAIL} ${MAIL}
|
|
|
|
|
|