Can you look at this shell script and tell me where my backups are being saved?
Can you look at this shell script and tell me where my backups are being saved? Thanks I am not knowledgeable with shell scripts and can't understand it very well.
# Initialize variables. #ORACLE_SID=ADCORPRD # what we are backingtrace="N" # for debuggingname=`whoami`t_date=`date +'%m%d%y%H%M'` ORATAB_FILE=/etc/oratab # oratab file locationPATH=/bin:/etc:/usr/bin:/usr/sbin:/usr/local/bin:/home/backup/binSRC_SYSTEM=gcunx2DST_SYSTEM=hqunx2SCRIPT_DIR=/home/scripts/backup/hot/$ORACLE_SIDSCRIPT_DIR1=/home/scripts/notifyLOG_DIR=/home/scripts/backup/hot/$ORACLE_SID/logLOG_FILE=/home/scripts/backup/hot/$ORACLE_SID/log/$ORACLE_SID.$t_dateARCHIVE_LOG_DEST=""########################################################################if [ -z $SCRIPT_DIR ] ; then echo "SCRIPT_DIR not set, Exiting" exit 5else if ! [ -d $SCRIPT_DIR ] ; then echo "SCRIPT_DIR nonexistant or Invalid. Exiting" exit 4 fificd $SCRIPT_DIR######################################################################### Quick sanity check to make sure we are running as oracle.if [ $name != 'oracle' ] ; then echo "You must be oracle to run this program" exit 1fi######################################################################### Make sure that the instance name exists in the oratab file to# insure that the variables get set correctly. If not bail out now.grep $ORACLE_SID $ORATAB_FILE > /dev/nullret_val=$?if [ $ret_val -ne 0 ] ; then # No Oratab entry echo "Invalid SID $ORACLE_SID in ORATAB, Exiting" exit 4fi## Check to see that the ORACLE_SID variable contains something meaningfulif [ -z $ORACLE_SID ] ; then echo "Oracle SID not set or Invalid. Exiting" exit 5fi########################################################################## Have oracle script set the appropriate shell variables#export ORAENV_ASK="NO" # set oracle paths etc. /usr/local/bin/oraenv###################################################################### Remove stuff left over since last run.#rm -f errfile # last error filerm -f ex_hotbackup.sql # last command file###################################################################### Query Oracle to determine directories where things are located.# Determine where the User Dump Files are located# First determine where trace file is located.USER_DUMP_DEST=`sqlplus -s / << EOFset feedback off;set echo off;set heading off;set pagesize 0;select value from v\\$parameter where name = 'user_dump_dest';quit;EOF`if [ -z $USER_DUMP_DEST ] ; then echo "USER_DUMP_DEST not set, Exiting" exit 5else if ! [ -d $USER_DUMP_DEST ] ; then echo "USER_DUMP_DEST nonexistant or Invalid. Exiting" exit 5 fifi###################################################################### Backup the current control file to trace in case we need it.if [ $trace = 'Y' ] ; then echo "Creating and Backing up Trace Control file" read afisqlplus -s / << EOFset feedback off;set echo off;alter database backup controlfile to trace;quit;EOF> /dev/null# Now move the tracefile we just created to the backup directory.# Look in the user dump dest (where Oracle writes controlfile), and # find the 10 newest files and examine each to see if it is a controlfile.# Copy the first backup controlfile to destination directory.ls -1t $USER_DUMP_DEST/*.trc | head | while read t_filedo grep -l "CREATE CONTROLFILE DATABASE" $t_file > /dev/null # is a ctl file? retval=$? if [ $retval -eq 1 ]; then # yep, copy it fname=backup_controlfile.$ORACLE_SID mv $t_file $SCRIPT_DIR/$fname rcp $SCRIPT_DIR/$fname $DST_SYSTEM:$SCRIPT_DIR/$fname if ! [ -s $SCRIPT_DIR/$fname ]; then echo "Warning: Controlfile could not be copied " fi break; fidone############################################################################# Generate script to take each tablespace offline, and # back up all the datafiles that comprise the tablespace.#if [ $trace = 'Y' ] ; then echo "Generating Scriptfile for hotbackup" read afisqlplus -s / @gen_hotbackup.sql | awk -f gen_hotbackup.awk -v dest_sys=$DST_SYSTEM > ex_hotbackup.sql###################################################################### test to see if the SQL we just created actually existsif ! [ -s $SCRIPT_DIR/ex_hotbackup.sql ] ; then echo "Backup Script missing or 0 length. Exiting" exit 7fi###################################################################### test to see if the SQL we just created contains any errors if [ -s $SCRIPT_DIR/ex_hotbackup.sql ] ; then grep 'ORA-' $SCRIPT_DIR/ex_hotbackup.sql > /dev/null ret_val=$? if [ $ret_val -eq 0 ] ; then echo "Backup Script Contains Errors. See $SCRIPT_DIR/ex_hotbackup.sql. Exiting" exit 8 fielse echo "Backup Datafile missing or 0 length. Exiting" exit 8fi###################################################################### here is where the main portion of the backup gets done. Go ahead and# run the script we just created.echo "BACKUP Started at `date`" > $LOG_FILEif [ $trace = 'Y' ] ; then echo "Executing Backup SQL"fisqlplus -s / @$SCRIPT_DIR/ex_hotbackup.sql >> $LOG_FILEecho "BACKUP Ended at `date`" >> $LOG_FILEgrep 'ORA-' $LOG_FILE > /dev/nullret_val=$?if [ $ret_val -eq 0 ] ; then echo "WARNING Backup Script Contains Errors." echo "See $LOG_FILE Exiting"fi###################################################################### Force a log switch, and then copy all but the last file to the destinationif [ $trace = 'Y' ] ; then echo "Forcing a log switch" #read afiSWITCH=`sqlplus -s / << EOFset feedback off;set echo off;set heading off;set pagesize 0;alter system switch logfile;quit;EOF`###################################################################### test to see if the errfile created by the script existsif ! [ -s $SCRIPT_DIR/errfile ] ; then echo "Warning errfile missing or 0 length" exit 9fi#################################### Notify of success if notify.good exists#ret_val=`cat errfile | awk '{ x+=$1} END{print x}'`if [ $ret_val -eq 0 ] ; then SUBJ="$ORACLE_SID Hotbackup Successful" if [ -s $SCRIPT_DIR1/notify.good ] ; then cat $LOG_FILE | sed -e '/^$/d'|mail -s "$SUBJ" `cat $SCRIPT_DIR1/notify.good` fielse SUBJ="$ORACLE_SID Hotbackup FAILURE" if [ -s $SCRIPT_DIR1/notify.list ] ; then echo $SUBJ | mail -s "$SUBJ" `cat $SCRIPT_DIR1/notify.list` fi cat $LOG_FILE | sed -e '/^$/d'|mail -s "$SUBJ" `cat $SCRIPT_DIR1/notify.list`fi####################################################################### Remove any log files created by this script that are older than 10 daysfind $SCRIPT_DIR/log \( -name "$ORACLE_SID.*" \) -mtime +10 -exec rm {} \;exit 0