#!/bin/sh #bcpyrght #*************************************************************************** #* $VRTScprght: Copyright 1993 - 2011 Symantec Corporation, All Rights Reserved $ * #*************************************************************************** #ecpyrght # #NOTE:IF your SAP user (in this script oradep) runs in C shell, environmental #variables can not be exported. In that case, you should modify this script to #work in your environment. For example: # SAP_SERVER=$SAP_SERVER; export SAP_SERVER; (Correct for Bourne and Korn shells) # can change into # setenv SAP_SERVER $SAP_SERVER; (Correct for C shell) # # #This environment variable are created by Netbackup (bphdb) # echo "SAP_SCHEDULED = $SAP_SCHEDULED" echo "SAP_USER_INITIATED = $SAP_USER_INITIATED" echo "SAP_SERVER = $SAP_SERVER" echo "SAP_POLICY = $SAP_POLICY" echo "SAP_SCHED = $SAP_SCHED" echo "SAP_SNC_SCHED = $SAP_SNC_SCHED" RETURN_STATUS=0 # SAP_ENV - Holds environmental variables. SAP_ENV="" # # If SAP_SERVER exists then export it to make it available to backint. # if [ -n "$SAP_SERVER" ] then SAP_ENV="$SAP_ENV SAP_SERVER=$SAP_SERVER; export SAP_SERVER;" #if Oracle DBA acount(oradep user) uses C Shell,comment the above line and uncomment the next line # SAP_ENV="$SAP_ENV setenv SAP_SERVER $SAP_SERVER;" fi # # If SAP_POLICY exists then export it to make it available to backint. # if [ -n "$SAP_POLICY" ] then SAP_ENV="$SAP_ENV SAP_POLICY=$SAP_POLICY; export SAP_POLICY;" #if Oracle DBA account(oradep user) uses C Shell, comment the above line and uncomment the next line # SAP_ENV="$SAP_ENV setenv SAP_POLICY $SAP_POLICY;" fi # # If SAP_SCHED exists then export it to make it available to backint. # if [ -n "$SAP_SCHED" ] then SAP_ENV="$SAP_ENV SAP_SCHED=$SAP_SCHED; export SAP_SCHED;" #if Oracle DBA account(oradep user) uses C Shell, comment the above line and uncomment the next line # SAP_ENV="$SAP_ENV setenv SAP_SCHED $SAP_SCHED;" fi # # If SAP_SNC_SCHED exists then export it to make it available to backint. # if [ -n "$SAP_SNC_SCHED" ] then SAP_ENV="$SAP_ENV SAP_SNC_SCHED=$SAP_SNC_SCHED; export SAP_SNC_SCHED;" #if Oracle DBA account(oradep user) uses C Shell, comment the above line and uncomment the next line # SAP_ENV="$SAP_ENV setenv SAP_SNC_SCHED $SAP_SNC_SCHED;" fi if [ "$SAP_FULL" = "1" ] then # # Full online backup with dynamic BEGIN/END BACKUP switch # CMD_LINE="$SAP_ENV brbackup -u / -c -d util_file -t online -m all" # # The username on the "su" command needs to be replaced with the correct user # name. # echo "Execute $CMD_LINE" su - oradep -c "$CMD_LINE" RETURN_STATUS=$? # # save and delete archive logs # if [ $RETURN_STATUS -eq 0 ] then timeStamp=`date '+%m%d%y%H%M%S'` ; br_out_file="/tmp/brarchive_out.${timeStamp}" ; CMD_LINE="$SAP_ENV brarchive -u / -c -d util_file -sd > $br_out_file" # # The username on the "su" command needs to be replaced with the correct user # name. # echo "Execute $CMD_LINE" su - oradep -c "$CMD_LINE" RETURN_STATUS=$? # If there were no redo logs to backup, brarchive will return 1. But if 1 is # returned to bphdb, job will appear as failed in the activity monitor. To # prevent Netbackup failure, check return code from brarchive. If the return code # is 1, check for message code BR0013W in the output of brarchive. If this message # is present, then there were no redo logs present to backup and its not a failure. # So in that case return 0 to bphdb. if [ $RETURN_STATUS = 1 ]; then su - oradep -c "grep 'BR0*13W' $br_out_file > /dev/null" if [ $? = 0 ]; then RETURN_STATUS=0 fi fi su - oradep -c "cat $br_out_file;rm $br_out_file" fi elif [ "$SAP_INCR" = "1" ] then timeStamp=`date '+%m%d%y%H%M%S'` ; br_out_file="/tmp/brarchive_out.${timeStamp}" ; CMD_LINE="$SAP_ENV brarchive -u / -c -d util_file -s > $br_out_file" # # The username on the "su" command needs to be replaced with the correct user # name. # echo "Execute $CMD_LINE" su - oradep -c "$CMD_LINE" RETURN_STATUS=$? # If there were no redo logs to backup, brarchive will return 1. But if 1 is # returned to bphdb, job will appear as failed in the activity monitor. To # prevent Netbackup failure, check return code from brarchive. If the return code # is 1, check for message code BR0013W in the output of brarchive. If this message # is present, then there were no redo logs present to backup and its not a failure. # So in that case return 0 to bphdb. if [ $RETURN_STATUS = 1 ]; then su - oradep -c "grep 'BR0*13W' $br_out_file > /dev/null" if [ $? = 0 ]; then RETURN_STATUS=0 fi fi su - oradep -c "cat $br_out_file;rm $br_out_file" fi exit $RETURN_STATUS