Veritas-bu

[Veritas-bu] Pre / Post Scripts on Backup Jobs with Streams- Revisit with

2009-06-04 14:46:40
Subject: [Veritas-bu] Pre / Post Scripts on Backup Jobs with Streams- Revisit with
From: doctorski <netbackup-forum AT backupcentral DOT com>
To: VERITAS-BU AT MAILMAN.ENG.AUBURN DOT EDU
Date: Thu, 04 Jun 2009 14:37:53 -0400
Simon,
          We use the following pre post scripts. Its not been tested at 6.5.3 
but should work i think ! 

bpstart_notify basically shuts "stuff" down in stream 1 and all other streams 
wait till stream1 lock file disappears.

bpend_notify identifies which is the last stream to complete and restarts 
"stuff"

bpstart_notify.POLICY_NAME script


@REM This bat script runs prior to the backup starting and can be used for 
stopping
@REM virus checker, services, databases etc, etc.

@REM If STREAM_NUMBER = 1 it calls C:\Batch\NetBackup_Stop_Services.bat which 
is a bat script maintained by Desktop.
@REM IF STREAM_NUMBER != 1 then it waits for STREAM1 shutdown to complete. Then 
exits.

@REM This script needs to be named in line with the POLICY for netbackup to 
recognise it.
@REM eg if POLICY name is SRV999AP_BKUP, this script needs to be called 
bpstart_notify.SRV999AP_BKUP.bat

@REM The bat script can be made schedule specific along the same lines of 
specific exclude lists
@REM eg bpstart_notify.SRV999AP_BKUP.SCHEDULE.bat

@REM %1 = Client name %2 = Policy %3 = Schedule %4 = FULL CINC or DIFF 

cd c:\"program files"\veritas\netbackup\logs

@set OUTFILE=c:\"program 
files"\veritas\netbackup\logs\%2_notify_STREAM%STREAM_NUMBER%.txt
@set LOCKFILE=c:\"program files"\veritas\netbackup\logs\%2_stream_lock.txt

@REM Exit if STREAM_NUMBER not set. Probable accidental execution of script !

if %STREAM_NUMBER% == "" goto END

@echo ">>>>>>>>>>>>>>>>>>>>> START OF %1 %2 %3 %4 STREAM NUMBER = 
%STREAM_NUMBER% <<<<<<<<<<<<<<<<<<<<<<" >> %OUTFILE%

@date /t >> %OUTFILE%
@time /t >> %OUTFILE%

@REM Check that the COMPLETE flag for this stream does not exist. Delete if it 
does, it shouldnt exist at start of backup.

if EXIST STREAM_NUMBER%STREAM_NUMBER%_COMPLETE.txt goto EXISTS

goto NOEXIST

:EXISTS

@echo ">>>> STREAM_NUMBER%STREAM_NUMBER%_COMPLETE.txt exists, deleting it" >> 
%OUTFILE%

@dir STREAM_NUMBER%STREAM_NUMBER%_COMPLETE.txt >> %OUTFILE%

@del STREAM_NUMBER%STREAM_NUMBER%_COMPLETE.txt

:NOEXIST

if %STREAM_NUMBER% == 1 goto SHUTDOWN

@REM sleep 60 to wait for STREAM1 to touch LOCKFILE

@sleep 60

goto LOCKCHECK

:LOCKLOOP

@date /t >> %OUTFILE%
@time /t >> %OUTFILE%

@echo "STREAM_NUMBER%STREAM_NUMBER% waiting for STREAM1 shutdown to 
finish.sleeping 30 secs" >> %OUTFILE%

sleep 30

:LOCKCHECK

if EXIST %LOCKFILE% goto LOCKLOOP

@echo "STREAM_NUMBER%STREAM_NUMBER% detected STREAM1 shutdown has finished" >> 
%OUTFILE%

:NOSHUTDOWN

@echo "STREAM_NUMBER = %STREAM_NUMBER% NOT RUNNING 
C:\batch\NetBackup_Stop_Services.bat" >> %OUTFILE%

goto END

:SHUTDOWN

@REM Create lock file so non STREAM1 streams wait for STREAM1 script to finish

@echo "STREAM_NUMBER%STREAM_NUMBER% populate LOCKFILE" >> %LOCKFILE%

@echo ">>>> STREAM_NUMBER = %STREAM_NUMBER% RUNNING 
C:\batch\NetBackup_Stop_Services.bat <<<<" >> %OUTFILE%

if EXIST c:\Batch\NetBackup_Stop_Services.bat goto RUNIT

@REM Create Dummy version if it doesnt exist.

@echo ">>>> c:\Batch\NetBackup_Stop_Services.bat  DOES NOT EXIST. Creating 
DUMMY version" >> %OUTFILE%

@echo sleep 90 > c:\Batch\NetBackup_Stop_Services.bat 

:RUNIT

call c:\Batch\NetBackup_Stop_Services.bat >> %OUTFILE%

@echo ">>>> DELETING %LOCKFILE% <<<<" >> %OUTFILE%

@del %LOCKFILE%

@date /t >> %OUTFILE%
@time /t >> %OUTFILE%

:END



bpend_notify.POLICY_NAME script

@REM This bat script runs after the backup ends and can be used for starting
@REM virus checker, services, databases etc, etc.

@REM It works out how many streams there, and the last stream to complete.
@REM If it is the last stream to complete it runs 
C:\Batch\NetBackup_Restart_Services.bat

@REM This script needs to be named in line with the POLICY for netbackup to 
recognise it.
@REM eg if POLICY name is SRV999AP_BKUP, this script needs to be called 
bpend_notify.SRV999AP_BKUP.bat

@REM The bat script can be made schedule specific along the same lines of 
specific exclude lists
@REM eg bpend_notify.SRV999AP_BKUP.SCHEDULE.bat

@REM %1 = Client name %2 = Policy %3 = Schedule %4 = FULL CINC or DIFF %5 = 
STATUS

cd C:\"program files"\veritas\netbackup\logs

@set OUTFILE=c:\"program 
files"\veritas\netbackup\logs\%2_notify_STREAM%STREAM_NUMBER%.txt

@REM Exit if STREAM_NUMBER not set. Probable accidental execution of script !

if %STREAM_NUMBER% == "" goto EXIT

@date /t >> %OUTFILE%
@time /t >> %OUTFILE%

if %5 == 0 goto BKUPOK
if %5 == 1 goto BKUPOK

@echo ">>>> STREAM_NUMBER = %STREAM_NUMBER% STATUS = %5 <<<<" >> %OUTFILE%
@echo ">>>> STREAM_NUMBER %STREAM_NUMBER% HAS FAILED EXITING WITH NO COMPLETE 
FLAG <<<<" >> %OUTFILE%

goto EXIT

:BKUPOK

@echo ">>>> STREAM_NUMBER = %STREAM_NUMBER% <<<<" >> %OUTFILE%

@echo %STREAM_NUMBER% > STREAM_NUMBER%STREAM_NUMBER%_COMPLETE.txt

@set NEW_STREAM_COUNT=%STREAM_COUNT%

:LOOP

if EXIST STREAM_NUMBER%NEW_STREAM_COUNT%_COMPLETE.txt goto NEXTCHECK

goto NOSTARTUP

:NEXTCHECK

@echo "STREAM_NUMBER%NEW_STREAM_COUNT%_COMPLETE.txt EXISTS" >> %OUTFILE%

set /a NEW_STREAM_COUNT-=1

if %NEW_STREAM_COUNT% == 0 goto STARTUP

goto LOOP

:STARTUP

if EXIST C:\Batch\NetBackup_Restart_Services.bat goto RUNIT

@REM Create Dummy version if it doesnt exist.

@echo ">>>> C:\Batch\NetBackup_Restart_Services.bat DOES NOT EXIST. Creating 
DUMMY version" >> %OUTFILE%

@echo sleep 1 > C:\Batch\NetBackup_Restart_Services.bat 

:RUNIT

@echo ">>>  ALL STREAM_NUMBER_COMPLETE.txt EXIST SO RUNNING 
C:\Batch\NetBackup_Restart_Services.bat <<<<" >> %OUTFILE%

@call C:\Batch\NetBackup_Restart_Services.bat >> %OUTFILE%

@del STREAM_NUMBER*_COMPLETE.txt

goto END

:NOSTARTUP

@echo "STREAM%STREAM_NUMBER% COMPLETED - HOWEVER ALL STREAM_NUMBER_COMPLETE.txt 
DO NOT EXIST SO NOT STARTING VIRUS CHECKER" >> %OUTFILE%

:END

@echo ">>>>>>>>>>>>>>>>>>>>> END OF %1 %2 %3 %4 SEV = %5 STREAM = 
STREAM%STREAM_NUMBER% <<<<<<<<<<<<<<<<<<<<<<" >> %OUTFILE%

@date /t >> %OUTFILE%
@time /t >> %OUTFILE%

:EXIT 


HTH - Darren

+----------------------------------------------------------------------
|This was sent by dzrichardson AT ybs.co DOT uk via Backup Central.
|Forward SPAM to abuse AT backupcentral DOT com.
+----------------------------------------------------------------------


_______________________________________________
Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu

<Prev in Thread] Current Thread [Next in Thread>