Need help with oracle backup script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Need help with oracle backup script

Shell Programming and Scripting


Tags
linux, mtime

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-21-2005
beilstwh beilstwh is offline
Registered User
 
Join Date: Jul 2004
Last Activity: 13 June 2008, 10:44 AM EDT
Location: New York State
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
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:


Code:
#!/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

Sponsored Links
    #2  
Old 09-21-2005
nir_s nir_s is offline
Registered User
 
Join Date: Jun 2004
Last Activity: 2 April 2012, 3:20 AM EDT
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #3  
Old 09-21-2005
beilstwh beilstwh is offline
Registered User
 
Join Date: Jul 2004
Last Activity: 13 June 2008, 10:44 AM EDT
Location: New York State
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
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?
    #4  
Old 09-21-2005
nir_s nir_s is offline
Registered User
 
Join Date: Jun 2004
Last Activity: 2 April 2012, 3:20 AM EDT
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
Maybe....
You don't need the "quit" at all.
The EOT exits you from sqlplus/svrmgrl

Nir
Sponsored Links
    #5  
Old 09-21-2005
beilstwh beilstwh is offline
Registered User
 
Join Date: Jul 2004
Last Activity: 13 June 2008, 10:44 AM EDT
Location: New York State
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
I have tried it with and without the quit
Sponsored Links
    #6  
Old 09-21-2005
tmarikle tmarikle is offline Forum Advisor  
Registered User
 
Join Date: Jan 2005
Last Activity: 27 September 2011, 12:36 PM EDT
Posts: 683
Thanks: 0
Thanked 4 Times in 4 Posts
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.
Sponsored Links
    #7  
Old 09-21-2005
nir_s nir_s is offline
Registered User
 
Join Date: Jun 2004
Last Activity: 2 April 2012, 3:20 AM EDT
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
I agree with tmarikle.
The EOT must be in the beginning of the line. Otherwise,you'll get syntax errors.

Nir
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can we restore omni oracle db backup Shirishlnx HP-UX 1 03-05-2012 07:55 PM
Oracle backup failures after SAN change. nokiae63 Solaris 2 08-16-2010 06:52 AM
Help with sed in Oracle DB backup script. talashil Shell Programming and Scripting 5 02-22-2010 03:29 PM
Oracle hot backup script issue dwiravi Shell Programming and Scripting 2 07-13-2008 12:27 AM
Shell script on Oracle hot backup got an error oradbus UNIX for Advanced & Expert Users 1 01-03-2006 11:35 AM



All times are GMT -4. The time now is 12:00 AM.