β06-02-2011 11:47 AM
Hi,
i have several policies witch backup files of SAP istances.
I using old custom scripts with tsm.
Three scripts, the first initialize the backup, the second selects the correct file. utl depending on the day, the third run the backup command.
I want to delete the script and use the script native NBU (C:\Programmi\VERITAS\NetBackup\DbExt\SAP\samples)
How do I create a single policy that through the application schedules make me 4 types of retention (daily, weekly, monthly and annual)
Example:
policy.sap.online
sch.aut schedule the script
sch.app.day save the file with retantion 15 day
sch.app.wee save the file with retantion 30 day
sch.app.mon save the file with retantion 12 months
ecc .....
thanks a lot
Solved! Go to Solution.
β06-30-2011 11:58 AM
I finished and tested the scripts.
I solved my problem in this way:
and
I select the files to be associated with backup command using the environment variable
%SAP_SNC_SCHED%
With the correctly file .SAP invokes the application scheduler by means of utl file which is set in the file .sap
To follow there are two scripts, one for windows one for unix.
REM @echo off
REM ---------------------------------------------------------------------------
REM SET ENVIRONMENT VARIABLES
REM ---------------------------------------------------------------------------
set SID=FVP
set LOG=c:\batch\log\last_bck_offline_%SID%.log
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM PRINT ENVIRONMENT VARIABLES
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo MASTER_SERVER : %SAP_SERVER% > %LOG%
echo. >> %LOG%
echo POLICY_NAME : %SAP_POLICY% >>%LOG%
echo. >>%LOG%
echo CLIENT_NAME : %SAP_CLIENT% >>%LOG%
echo. >>%LOG%
echo SCHEDUALZIONE_AUTOMATICA : %SAP_SNC_SCHED% >>%LOG%
echo. >>%LOG%
echo. >>%LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM SELECT CORRECTLY APPLICATION SCHEDULER
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
@if "%SAP_SNC_SCHED%" EQU "sch-aut.wee" (@set SAP_TYPE=nbu_weekly.sap)
@if "%SAP_SNC_SCHED%" EQU "sch-aut.mon" (@set SAP_TYPE=nbu_monthly.sap)
@if "%SAP_SNC_SCHED%" EQU "sch-aut.yee" (@set SAP_TYPE=nbu_yearly.sap)
@if "%SAP_SNC_SCHED%" EQU "sch-aut.day" (@set SAP_TYPE=nbu_daily.sap)
echo FILE_SAP_SELECTED=%SAP_TYPE% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM LAUNCH SCRIPT .CMD FOR ACTIVATE TIVOLI MAINTENANCE
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo START_TIVOLI_MAINTENANCE" >> %LOG%
echo. >> %LOG%
call C:\batch\sap\Start_sap_maint.cmd %SID%
set START_MAIN=%ERRORLEVEL%
echo START_MAIN=%START_MAIN% >> %LOG%
echo. >> %LOG%
echo STOP_ISTANZA %SID% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM START STOP ISTANCE
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
stopsap.exe name=%SID% nr=00 SAPDIAHOST=%COMPUTERNAME%
set ESITO_STOPSAP=%ERRORLEVEL%
echo ESITO_STOPSAP=%ESITO_STOPSAP% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM PUTTING BRBACKUP COMMAND
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
brbackup.exe -c -u user/password -t offline_force -p %ORACLE_HOME%\database\init%SID%.%SAP_TYPE% >> %LOG%
set ESITO_BRBACKUP=%ERRORLEVEL%
echo ESITO_BRBACKUP=%ESITO_BRBACKUP% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM STARTING ISTANCE SAP
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo START_ISTANZA %SID% >> %LOG%
echo. >> %LOG%
startsap.exe name=%SID% nr=00 SAPDIAHOST=%COMPUTERNAME%
set ESITO_STARTSAP=%ERRORLEVEL%
echo ESITO_STARTSAP=%ESITO_STARTSAP% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM STOPPING TIVOLI MAINTENANCE
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo STOP_TIVOLI_MAINTENANCE >> %LOG%
echo. >> %LOG%
call C:\batch\sap\Stop_sap_maint.cmd %SID%
set ESITO_STOPMAINT=%ERRORLEVEL%
echo ESITO_STOPMAINT=%ESITO_STOPMAINT% >> %LOG%
echo. >> %LOG%
echo. >> %LOG%
echo ############### REPORT STATUS CODE STEP SCRIPT ################## >> %LOG%
echo. >>%LOG%
echo. >>%LOG%
echo START_MAIN=%START_MAIN% >> %LOG%
echo. >>%LOG%
echo ESITO_STOPSAP=%ESITO_STOPSAP% >> %LOG%
echo. >>%LOG%
echo ESITO_BRBACKUP=%ESITO_BRBACKUP% >> %LOG%
echo. >>%LOG%
echo ESITO_STARTSAP=%ESITO_STARTSAP% >> %LOG%
echo. >>%LOG%
echo ESITO_STOPMAINT=%ESITO_STOPMAINT% >> %LOG%
echo. >>%LOG%
echo. >>%LOG%
echo. >>%LOG%
if %ESITO_BRBACKUP% NEQ 0 goto errormsg
echo BRBACKUP SUCCESSFUL >> %LOG%
if "%STATUS_FILE%" == "" goto end
if exist "%STATUS_FILE%" echo 0 > "%STATUS_FILE%"
goto end
:errormsg
echo Execution of BRBACKUP command failed - exiting >> %LOG%
if "%STATUS_FILE%" == "" goto end
if exist "%STATUS_FILE%" echo 1 > "%STATUS_FILE%"
:end
#!/bin/ksh
#
/usr/bin/date
sid=`echo SMP | tr '[A-Z]' '[a-z]'`
SID=`echo SMP | tr '[a-z]' '[A-Z]'`
HOST_NAME=`uname -n`
LOG=/var/opt/nbu/sap/bck_sap_offline_nbu.$SID
exec 1>$LOG
exec 2>$LOG
echo $LOG
echo "Start backup $HOST_NAME Instance $SID"
echo.
echo "Select configuration file .SAP for invoke correctly application scheduler"
echo.
###################### SELECT CORRECTLY APPLICATION SCHEDULER #############
[[ $SAP_SNC_SCHED = "sch-aut.day" ]] && UTL_TYPE="nbu_daily.sap"
[[ $SAP_SNC_SCHED = "sch-aut.wee" ]] && UTL_TYPE="nbu_weekly.sap"
[[ $SAP_SNC_SCHED = "sch-aut.mon" ]] && UTL_TYPE="nbu_monthly.sap"
[[ $SAP_SNC_SCHED = "sch-aut.yee" ]] && UTL_TYPE="nbu_yearly.sap"
echo "File .SAP Selected:" $UTL_TYPE
echo.
############################ Start Maintenance ############################
MAINT_TIME=7200
echo "Starting Maintenance of Second : " $MAINT_TIME
echo.
/opt/Tivoli/lcf/dat/1/on_maintenance.sh $MAINT_TIME ${SID}
ESITO_START_MAINTENANCE=$?
ESITO_START_MAINTENANCE=$ESITO_START_MAINTENANCE
echo "ESITO_START_MAINTENANCE=$ESITO_START_MAINTENANCE"
echo.
############################ Stop Istance SAP #############################
echo "Stop istance $SID Starting"
echo.
/bin/su - ${sid}adm -c "stopsap"
ESITO_STOP=$?
ESITO_STOPSAP=$ESITO_STOP
echo "ESITO_STOPSAP=$ESITO_STOPSAP"
echo.
############################ Verify Stop Istance SAP ######################
echo "Verify Stop Istance $SID"
if [ $ESITO_STOPSAP -gt 0 ]
then
/usr/local/tivoli/script/T-SendEvent.sh "Stopsap istanza ${SID} fallito" sap_backup_start CRITICAL backup sap_instance=${SID}
echo "Stopsap fallito"
echo.
fi
############################ Putting BRBACKUP COMMAND #####################
echo "Start BRBACKUP Command"
echo.
sleep 60
/bin/su - ora${sid} -c "brbackup -u user/password -c -p init${SID}.{$UTL_TYPE} -t offline_force -m all"
ESITO_BCK=$?
ESITO_BCK=$ESITO_BCK
echo "ESITO_BCK=$ESITO_BCK"
echo.
############################ START ISTANCE SAP ############################
echo "Backup End Start Istance $SID"
echo.
/bin/su - ${sid}adm -c "startsap"
ESITO_START=$?
ESITO_STARTSAP=$ESITO_START
echo "ESITO_STARTSAP=$ESITO_STARTSAP"
echo.
############################ VERIFY STEP STARTSAP #########################
echo "Verify Start Istance $SID"
echo.
if [ $ESITO_STARTSAP -gt 0 ]
then
/usr/local/tivoli/script/SendEvent.sh "Startsap istanza ${SID} fallito" sap_backup_end CRITICAL backup sap_instance=${SID}
echo "Startsap fallito"
echo.
fi
sleep 120
############################ Stop Maintenance #############################
echo "Stop Maintenance after backup"
echo.
/opt/Tivoli/lcf/dat/1/off_maintenance.sh ${SID}
ESITO_STOP_MAINTENANCE=$?
ESITO_STOP_MAINTENANCE=$ESITO_STOP_MAINTENANCE
echo "ESITO_STOP_MAINTENANCE=$ESITO_STOP_MAINTENANCE"
echo.
############################ REPORT EXECUTION SCRIPT STEP #################
echo.
echo " ############### REPORT STATUS CODE STEP SCRIPT ################## "
echo.
echo.
echo "ESITO_START_MAINTENANCE=$ESITO_START_MAINTENANCE"
echo.
echo "ESITO_STOPSAP=$ESITO_STOPSAP"
echo.
echo "ESITO_BCK=$ESITO_BCK"
echo.
echo "ESITO_STARTSAP=$ESITO_STARTSAP"
echo.
echo "ESITO_STOP_MAINTENANCE=$ESITO_STOP_MAINTENANCE"
############################ TEST STEP BACKUP ############################
############################ IF 0 BACKUP OK ############################
echo.
echo " Test ESITO_BCK if = 0 Backup successful"
echo.
/usr/bin/date
if [ $ESITO_BCK -eq 0 ]
then
RETURN_STATUS=0
fi
echo "RETURN_STATUS=$RETURN_STATUS"
echo.
echo " BACKUP CLOSED "
echo.
exit $RETURN_STATUS
Hello Thanks !!!!
β06-06-2011 01:26 AM
Hi,
NetBackup can't do this for Database Agent backups. I have however found a way to trick it, you can check the post below for more details. Little tricky and could be dangerous if not monitored correctly......
https://www-secure.symantec.com/connect/forums/storage-lifecycle-policies-and-oracle-backups#comment-5653501
β06-08-2011 11:38 PM
Hi,
I would recommend you to create one sap policy and configure the init<sid>.utl file to specify the policy but not the schedule, you can hash it out.
In the sap policy reate a full automatic schedule and an application backup schedule for the daily backup and open the backup window for the time you want it to run. I.e mon-fri from 8PM to 11PM. Set retention to 15 days for the application backup schedule.
Create a new full automatic schedule and an application backup schedule for the weekly backup and open the backup window when you want this to run, I.e Sun 8PM 11PM and set retention for this application backup to 30 days.
Create a new full automatic and application schedule for the monthly backup and open the backup window when you want this to run. I.e last Saturday in every month at 1AM- 3AM and change the retention period for the application backup to 12 months.
Do the same for the annual backup and open the backup window at a time when no other backup windows is opened in the policy.
You might have to tweek this and find your best timing to do this. You only want one application backup schedule open in the policy at the time the backup is running with the correct retention.
I hope this helps.
/Oddy
β06-10-2011 06:05 AM
Thank for the reply.
The best solution for my case is that of Oddy.
I delete the application schedule under SAP.UTL file and setting the correctly haurs for the application.
So i use only script for all retention. I try to do this and after i write my experience.
Thanks at all.
β06-30-2011 11:58 AM
I finished and tested the scripts.
I solved my problem in this way:
and
I select the files to be associated with backup command using the environment variable
%SAP_SNC_SCHED%
With the correctly file .SAP invokes the application scheduler by means of utl file which is set in the file .sap
To follow there are two scripts, one for windows one for unix.
REM @echo off
REM ---------------------------------------------------------------------------
REM SET ENVIRONMENT VARIABLES
REM ---------------------------------------------------------------------------
set SID=FVP
set LOG=c:\batch\log\last_bck_offline_%SID%.log
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM PRINT ENVIRONMENT VARIABLES
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo MASTER_SERVER : %SAP_SERVER% > %LOG%
echo. >> %LOG%
echo POLICY_NAME : %SAP_POLICY% >>%LOG%
echo. >>%LOG%
echo CLIENT_NAME : %SAP_CLIENT% >>%LOG%
echo. >>%LOG%
echo SCHEDUALZIONE_AUTOMATICA : %SAP_SNC_SCHED% >>%LOG%
echo. >>%LOG%
echo. >>%LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM SELECT CORRECTLY APPLICATION SCHEDULER
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
@if "%SAP_SNC_SCHED%" EQU "sch-aut.wee" (@set SAP_TYPE=nbu_weekly.sap)
@if "%SAP_SNC_SCHED%" EQU "sch-aut.mon" (@set SAP_TYPE=nbu_monthly.sap)
@if "%SAP_SNC_SCHED%" EQU "sch-aut.yee" (@set SAP_TYPE=nbu_yearly.sap)
@if "%SAP_SNC_SCHED%" EQU "sch-aut.day" (@set SAP_TYPE=nbu_daily.sap)
echo FILE_SAP_SELECTED=%SAP_TYPE% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM LAUNCH SCRIPT .CMD FOR ACTIVATE TIVOLI MAINTENANCE
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo START_TIVOLI_MAINTENANCE" >> %LOG%
echo. >> %LOG%
call C:\batch\sap\Start_sap_maint.cmd %SID%
set START_MAIN=%ERRORLEVEL%
echo START_MAIN=%START_MAIN% >> %LOG%
echo. >> %LOG%
echo STOP_ISTANZA %SID% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM START STOP ISTANCE
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
stopsap.exe name=%SID% nr=00 SAPDIAHOST=%COMPUTERNAME%
set ESITO_STOPSAP=%ERRORLEVEL%
echo ESITO_STOPSAP=%ESITO_STOPSAP% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM PUTTING BRBACKUP COMMAND
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
brbackup.exe -c -u user/password -t offline_force -p %ORACLE_HOME%\database\init%SID%.%SAP_TYPE% >> %LOG%
set ESITO_BRBACKUP=%ERRORLEVEL%
echo ESITO_BRBACKUP=%ESITO_BRBACKUP% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM STARTING ISTANCE SAP
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo START_ISTANZA %SID% >> %LOG%
echo. >> %LOG%
startsap.exe name=%SID% nr=00 SAPDIAHOST=%COMPUTERNAME%
set ESITO_STARTSAP=%ERRORLEVEL%
echo ESITO_STARTSAP=%ESITO_STARTSAP% >> %LOG%
echo. >> %LOG%
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
REM STOPPING TIVOLI MAINTENANCE
REM ---------------------------------------------------------------------------
REM ---------------------------------------------------------------------------
echo STOP_TIVOLI_MAINTENANCE >> %LOG%
echo. >> %LOG%
call C:\batch\sap\Stop_sap_maint.cmd %SID%
set ESITO_STOPMAINT=%ERRORLEVEL%
echo ESITO_STOPMAINT=%ESITO_STOPMAINT% >> %LOG%
echo. >> %LOG%
echo. >> %LOG%
echo ############### REPORT STATUS CODE STEP SCRIPT ################## >> %LOG%
echo. >>%LOG%
echo. >>%LOG%
echo START_MAIN=%START_MAIN% >> %LOG%
echo. >>%LOG%
echo ESITO_STOPSAP=%ESITO_STOPSAP% >> %LOG%
echo. >>%LOG%
echo ESITO_BRBACKUP=%ESITO_BRBACKUP% >> %LOG%
echo. >>%LOG%
echo ESITO_STARTSAP=%ESITO_STARTSAP% >> %LOG%
echo. >>%LOG%
echo ESITO_STOPMAINT=%ESITO_STOPMAINT% >> %LOG%
echo. >>%LOG%
echo. >>%LOG%
echo. >>%LOG%
if %ESITO_BRBACKUP% NEQ 0 goto errormsg
echo BRBACKUP SUCCESSFUL >> %LOG%
if "%STATUS_FILE%" == "" goto end
if exist "%STATUS_FILE%" echo 0 > "%STATUS_FILE%"
goto end
:errormsg
echo Execution of BRBACKUP command failed - exiting >> %LOG%
if "%STATUS_FILE%" == "" goto end
if exist "%STATUS_FILE%" echo 1 > "%STATUS_FILE%"
:end
#!/bin/ksh
#
/usr/bin/date
sid=`echo SMP | tr '[A-Z]' '[a-z]'`
SID=`echo SMP | tr '[a-z]' '[A-Z]'`
HOST_NAME=`uname -n`
LOG=/var/opt/nbu/sap/bck_sap_offline_nbu.$SID
exec 1>$LOG
exec 2>$LOG
echo $LOG
echo "Start backup $HOST_NAME Instance $SID"
echo.
echo "Select configuration file .SAP for invoke correctly application scheduler"
echo.
###################### SELECT CORRECTLY APPLICATION SCHEDULER #############
[[ $SAP_SNC_SCHED = "sch-aut.day" ]] && UTL_TYPE="nbu_daily.sap"
[[ $SAP_SNC_SCHED = "sch-aut.wee" ]] && UTL_TYPE="nbu_weekly.sap"
[[ $SAP_SNC_SCHED = "sch-aut.mon" ]] && UTL_TYPE="nbu_monthly.sap"
[[ $SAP_SNC_SCHED = "sch-aut.yee" ]] && UTL_TYPE="nbu_yearly.sap"
echo "File .SAP Selected:" $UTL_TYPE
echo.
############################ Start Maintenance ############################
MAINT_TIME=7200
echo "Starting Maintenance of Second : " $MAINT_TIME
echo.
/opt/Tivoli/lcf/dat/1/on_maintenance.sh $MAINT_TIME ${SID}
ESITO_START_MAINTENANCE=$?
ESITO_START_MAINTENANCE=$ESITO_START_MAINTENANCE
echo "ESITO_START_MAINTENANCE=$ESITO_START_MAINTENANCE"
echo.
############################ Stop Istance SAP #############################
echo "Stop istance $SID Starting"
echo.
/bin/su - ${sid}adm -c "stopsap"
ESITO_STOP=$?
ESITO_STOPSAP=$ESITO_STOP
echo "ESITO_STOPSAP=$ESITO_STOPSAP"
echo.
############################ Verify Stop Istance SAP ######################
echo "Verify Stop Istance $SID"
if [ $ESITO_STOPSAP -gt 0 ]
then
/usr/local/tivoli/script/T-SendEvent.sh "Stopsap istanza ${SID} fallito" sap_backup_start CRITICAL backup sap_instance=${SID}
echo "Stopsap fallito"
echo.
fi
############################ Putting BRBACKUP COMMAND #####################
echo "Start BRBACKUP Command"
echo.
sleep 60
/bin/su - ora${sid} -c "brbackup -u user/password -c -p init${SID}.{$UTL_TYPE} -t offline_force -m all"
ESITO_BCK=$?
ESITO_BCK=$ESITO_BCK
echo "ESITO_BCK=$ESITO_BCK"
echo.
############################ START ISTANCE SAP ############################
echo "Backup End Start Istance $SID"
echo.
/bin/su - ${sid}adm -c "startsap"
ESITO_START=$?
ESITO_STARTSAP=$ESITO_START
echo "ESITO_STARTSAP=$ESITO_STARTSAP"
echo.
############################ VERIFY STEP STARTSAP #########################
echo "Verify Start Istance $SID"
echo.
if [ $ESITO_STARTSAP -gt 0 ]
then
/usr/local/tivoli/script/SendEvent.sh "Startsap istanza ${SID} fallito" sap_backup_end CRITICAL backup sap_instance=${SID}
echo "Startsap fallito"
echo.
fi
sleep 120
############################ Stop Maintenance #############################
echo "Stop Maintenance after backup"
echo.
/opt/Tivoli/lcf/dat/1/off_maintenance.sh ${SID}
ESITO_STOP_MAINTENANCE=$?
ESITO_STOP_MAINTENANCE=$ESITO_STOP_MAINTENANCE
echo "ESITO_STOP_MAINTENANCE=$ESITO_STOP_MAINTENANCE"
echo.
############################ REPORT EXECUTION SCRIPT STEP #################
echo.
echo " ############### REPORT STATUS CODE STEP SCRIPT ################## "
echo.
echo.
echo "ESITO_START_MAINTENANCE=$ESITO_START_MAINTENANCE"
echo.
echo "ESITO_STOPSAP=$ESITO_STOPSAP"
echo.
echo "ESITO_BCK=$ESITO_BCK"
echo.
echo "ESITO_STARTSAP=$ESITO_STARTSAP"
echo.
echo "ESITO_STOP_MAINTENANCE=$ESITO_STOP_MAINTENANCE"
############################ TEST STEP BACKUP ############################
############################ IF 0 BACKUP OK ############################
echo.
echo " Test ESITO_BCK if = 0 Backup successful"
echo.
/usr/bin/date
if [ $ESITO_BCK -eq 0 ]
then
RETURN_STATUS=0
fi
echo "RETURN_STATUS=$RETURN_STATUS"
echo.
echo " BACKUP CLOSED "
echo.
exit $RETURN_STATUS
Hello Thanks !!!!