Need help with oracle backup script

I have written a script to perfrom a cold backup on an oracle database. The script is failing everytime. Can anyone tell me what (stupid) error I am making.

The output from the uname command follows

Linux rayora 2.2.14-6.1.1smp #1 SMP Thu Apr 13 19:55:55 EDT 2000 i686 unknown

The error that I am getting on my script is:

Oracle Server Manager Release 3.1.7.0.0 - Production

Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved.

Oracle8i Enterprise Edition Release 8.1.7.0.1 - Production
With the Partitioning option
JServer Release 8.1.7.0.1 - Production

SVRMGR> Connected.
SVRMGR> Database closed.
Database dismounted.
ORACLE instance shut down.
SVRMGR> Server Manager complete.
/home/rf/bin/oracle_backup.sh: /home/rf/bin/oracle_backup.sh: line 53: syntax error: unexpected end of file

The script that I wrote follows:

#!/bin/sh
########################################################################
# Program Name - backup_full.sh                                        #
# Purpose - To perform a cold backup of the Rayora database and the    #
#            Archive Logs                                              #
#                                                                      #
# Author - xxx.xxx.xxx                                       #
# Date last Change - 09/14/2005                                        #
########################################################################

. /home/rf/common/cron_oracle_env.sh
LOG_FILE=/home/oracle/backup.log
########################################################################
# Execute the backup procedure                                         #
########################################################################
echo `date +%c` >> $LOG_FILE
echo "Database RAYORA BACKUP starting." >> $LOG_FILE
svrmgrl <<EOT
connect internal
shutdown immediate
quit
EOT
if [ $? -eq 0 ]
 then
 echo "Database RAYORA shut down." >> $LOG_FILE
 echo "Previous Backup is being removed." >> $LOG_FILE
 touch /home/oracle/backup/junk
 rm /home/oracle/backup/*
 echo "Cold backup being performed." >> $LOG_FILE
 cp -p -f -v /home/oracle/oraInventory/oradata/rayora/*  /home/oracle/backup/
 echo "Cold backup of archive logs being performed." >> $LOG_FILE
 mv -f -v /home/oracle/oraInventory/oradata/arch/*       /home/oracle/backup/
 echo "Restarting Database RAYORA." >> $LOG_FILE
 svrmgrl <<EOT
 connect internal
 startup
 quit
 EOT
 if [ $? -eq 0 ]
 then
   echo "Database RAYORA started up." >> $LOG_FILE
 else
   echo "Database RAYORA will NOT start up." >> $LOG_FILE
 fi
 echo "Moving the backup files to the NFS share." >> $LOG_FILE
 cp -p -f -v /home/oracle/backup/* /usr/local/backup/oracle_back/
 echo "Remove Archive Logs older then seven (7) days" >> $LOG_FILE
 find /usr/local/backup/oracle_back/ -type f -name "*arc" -mtime 6 -exec rm {}\;
else
 echo "Database RAYORA failed to shut down." >> $LOG_FILE
fi
echo `date +%c` >> $LOG_FILE
echo "Database RAYORA BACKUP has completed." >> $LOG_FILE

You failed in the "EOT" after the "shutdown immediate" :
svrmgrl <<EOT
connect internal
shutdown immediate
quit
EOT

Check if there is a space after "EOT".
I also failed in the past due to blank space after EOT sign.

Nir

I checked the script on the server and there are no spaces on the "EOT" line, either before or after the EOT. However there was a blank space after the "quit" on the previous line, will this cause problems?

Maybe....
You don't need the "quit" at all.
The EOT exits you from sqlplus/svrmgrl

Nir

I have tried it with and without the quit

Your script shows whitespace before EOT which needs to be removed. You indicated that you checked the script on the server but you CODE example shows whitespace. Recheck this since it will hork you up.

I agree with tmarikle.
The EOT must be in the beginning of the line. Otherwise,you'll get syntax errors.

Nir

That took care of it, I was looking for white space after, not before.

Thanks for the help.

You can indent, but only if you use tabs and <<-
From man bash: