cancel
Showing results for 
Search instead for 
Did you mean: 

Backup Script for SAP in SOLARIS

Former Member
0 Kudos

Hi , I have a My Sap ERP 2004 ECC 5.0 installed on SOLARIS platform. Now I need to take backup on weekends , can somebody give me a backup scripts which first stops SAP and then starts taking backup, using ufsdump command , Now the thing is that I have to login as user sapsid first to stop sap and when I use the script

su - cdvadm

stopsap

exit

su - oracdv

lsnrctl stop

exit

./backup

Here Backup is the name of the script that contains ufsdump commands, it executes just the first line of the script ie su - cdvadm and then stops and does not proceed further, can anybody help ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mike

I have tried the same as u had suggested already but it is showing the same crontab file for both root as well as cdvadm so I am kinda confused, ny Idea about this is the crontab file common for all the users?

I know it sounds strange as I have also heard that every users has its own crontab

Former Member
0 Kudos

Hi Karan,

I am assuming it expects you to type the password when it runs "su" (if you are not using root or equivalent to run it). I'd suggest you to use crontab (e.g. to schedule stopsap execution by cdvadm and then (let's say after 10 minutes) schedule "lsnrctl stop" (in the cron for oracdv). I'd also add checks to see if SAP/Oracle is really down and listener has been stopped before starting you backup script (you can do it analyzing "ps" output similar to "ps -ef | grep oracdv |wc -l" )

Regards,

Mike

Former Member
0 Kudos

You really only need to stop the SAP database.

If you agree with this philosophy, then you can stop the SAP database with a shell script similar to this (HPUX commands):

initialize()

{

  1. Define Oracle Environment

#

export ORACLE_SID=$1

  1. Setup Oracle Environment

#

. /oracle/${ORACLE_SID}/utils/.dbenv_$

  1. DBAs to receive email notification in case of failure
.ksh # export DBA_GROUP=`cat /oracle/$/.dbagroup`

#export DBA_GROUP="mr911080@aeraenergy.com"

  1. Define Log File

#

export DT=`date +%Y%m%d`

  1. Lowercase ORACLE_SID so that the log can write to the log directory

typeset -l LOWER_SID

LOWER_SID=$ export LOG_DIR=/export/`hostname`/$adm/backup_log export LOG_FILE=$LOG_DIR/db_sap_stop_$_$.log

echo "" > $LOG_FILE

  1. Define time stamp

export datestamp=`date '+%m_%d_%y'`

  1. Program and logfile identification messages

#

log_msg "/export/`hostname`/$adm/backup_script/maestro/db_sap_stop.ksh Started on `hostname` on `date`" log_msg "Log File: $

  1. No of days to keep the log files
  2. Print messages to a log file
  3. Notify DBAs. There is no "exit 1" because errors will be resolved
  4. during business hours.
            • MAIN PROGRAM *****
  5. ORACLE_SID must be passed to program. Terminate with error code if absent.
  6. $1 is ORACLE_SID. Initialize variables.
  7. Start the database and SAP application
" log_msg "`date`" # DAYS_KEPT=30 } # log_msg() { echo "$1" echo "\n$1" >> $LOG_FILE } # log_severe_msg() { log_msg "$1" mailx -s "${1}" $DBA_GROUP <<EOF `cat $LOG_FILE` EOF } #************************************************************************** #************************************************************************** # if [ $# -ne 1 ]; then echo "Usage: db_sap_stop.ksh ORACLE_SID" exit 1 fi # initialize $1 # . $HOME/.sapenv_`hostname`.sh . $HOME/.profile stopsap if [ $? -eq 0 ]; then log_msg "$ORACLE_SID on `hostname` and the SAP Application was successfully shutdown on `date`" else log_severe_msg "Severe Error: $ Database or SAP Application Failed to Shutdown"

exit 1

fi

  1. Purge log files older than 30 days

#

find $LOG_DIR -name "db_sapstop*.log" -mtime +$DAYS_KEPT -print -exec rm {} \; >> $LOG_FILE

This was writtin on HPUX, so some commands will differ, but you get the idea.