Veritas-bu

Re: [Veritas-bu] Pre / Post Scripts on Backup Jobs withStreams-Revisit with

2009-06-05 09:01:02
Subject: Re: [Veritas-bu] Pre / Post Scripts on Backup Jobs withStreams-Revisit with
From: "Preston, Doug" <dpreston AT LANDAM DOT com>
To: "WEAVER, Simon \(external\)" <simon.weaver AT astrium.eads DOT net>, <VERITAS-BU AT mailman.eng.auburn DOT edu>
Date: Fri, 5 Jun 2009 08:57:52 -0400
I use pstools psservice.exe command available from Microsoft for free.
http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx
http://download.sysinternals.com/Files/SysinternalsSuite.zip

Usage: psservice [\\Computer [-u Username [-p Password]]] <cmd> <optns>



Parent_end_notify.cmd
@REM
@REM ---------------------------------------------------------------------------
@setlocal ENABLEEXTENSIONS
@set LISTPATHS="%~dp0\goodies\listpaths"
@for /F "delims=|" %%p in ('%LISTPATHS% /s NB_MAIL_SCRIPT') do @set 
NB_MAIL_SCRIPT="%%p"
@set OUTF="%~dp0\PARENT_END_CALLED"
@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p
@if "%6" == "" goto BadParams
@if "%7" == "" goto GoodParams
:BadParams
@echo %DATE% parent_end_notify expects 6 parameters: %* >> %OUTF%
@goto EndMain
:GoodParams
G:\pstools\psservice \\%1 start  "Symantec AntiVirus"
@if exist %OUTF% del %OUTF%
@echo %DATE% ----------------------------- >> %OUTF%
@echo %DATE%        CLIENT:  %1 >> %OUTF%
@echo %DATE%        POLICY:  %2 >> %OUTF%
@echo %DATE%      SCHEDULE:  %3 >> %OUTF%
@echo %DATE% SCHEDULE TYPE:  %4 >> %OUTF%
@echo %DATE%        STATUS:  %5 >> %OUTF%
@echo %DATE%        STREAM:  %6 >> %OUTF%
@echo %DATE% ----------------------------- >> %OUTF%
:EndMain
@endlocal
@REM - End of Main Program -----------------------------------------------------



Parent_start_notify.cmd
@REM
@REM ---------------------------------------------------------------------------
@setlocal ENABLEEXTENSIONS
@set LISTPATHS="%~dp0\goodies\listpaths"
@for /F "delims=|" %%p in ('%LISTPATHS% /s NB_MAIL_SCRIPT') do @set 
NB_MAIL_SCRIPT="%%p"
@set OUTF="%~dp0\PARENT_START_CALLED"
@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p
@if "%6" == "" goto BadParams
@if "%7" == "" goto GoodParams
:BadParams
@echo %DATE% parent_start_notify expects 6 parameters: %* >> %OUTF%
@goto EndMain
:GoodParams
@G:\pstools\psservice \\%1 stop  "Symantec AntiVirus"
@if exist %OUTF% del %OUTF%
@echo %DATE% ----------------------------- >> %OUTF%
@echo %DATE%        CLIENT:  %1 >> %OUTF%
@echo %DATE%        POLICY:  %2 >> %OUTF%
@echo %DATE%      SCHEDULE:  %3 >> %OUTF%
@echo %DATE% SCHEDULE TYPE:  %4 >> %OUTF%
@echo %DATE%        STATUS:  %5 >> %OUTF%
@echo %DATE%        STREAM:  %6 >> %OUTF%
@echo %DATE% ----------------------------- >> %OUTF%
:EndMain
@endlocal
@REM - End of Main Program -----------------------------------------------------



Stopav.bat

@echo stopping av on %1 >>g:\bpres
G:\pstools\psservice \\%1 stop  "Symantec AntiVirus" >>bpres


Startav.bat

@echo starting av on %1 >>g:\bpres
G:\pstools\psservice \\%1 start  "Symantec AntiVirus" >>bpres



Doug Preston
Systems Engineer
LandAmerica Financial Group, Inc. - 
1123 South Park View DR, 
Covina CA 91724 
Phone 626-339-5221 Ext 1104 
Email  dlpreston AT landam DOT com

------------------------------------------------------------------------------
NOTICE: This electronic mail transmission may constitute a communication that
is legally privileged. It is not intended for transmission to, or receipt by,
any unauthorized persons. If you have received this electronic mail
transmission in error,  notify the sender by reply e-mail so that our address
record can be corrected, then please delete it from your system without copying 
it.
-------------------------------------------------------------------------------


-----Original Message-----
From: veritas-bu-bounces AT mailman.eng.auburn DOT edu 
[mailto:veritas-bu-bounces AT mailman.eng.auburn DOT edu] On Behalf Of WEAVER, 
Simon (external)
Sent: Thursday, June 04, 2009 10:42 PM
To: VERITAS-BU AT mailman.eng.auburn DOT edu
Subject: Re: [Veritas-bu] Pre / Post Scripts on Backup Jobs withStreams-Revisit 
with

Hi Darren
I may take a snip of this and have a re-try in my test lab.

Thanks again for your help and advice
Simon 

-----Original Message-----
From: veritas-bu-bounces AT mailman.eng.auburn DOT edu
[mailto:veritas-bu-bounces AT mailman.eng.auburn DOT edu] On Behalf Of
doctorski
Sent: Thursday, June 04, 2009 7:38 PM
To: VERITAS-BU AT mailman.eng.auburn DOT edu
Subject: [Veritas-bu] Pre / Post Scripts on Backup Jobs with
Streams-Revisit with


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

This email (including any attachments) may contain confidential
and/or privileged information or information otherwise protected
from disclosure. If you are not the intended recipient, please
notify the sender immediately, do not copy this message or any
attachments and do not use it for any purpose or disclose its
content to any person, but delete this message and any attachments
from your system. Astrium disclaims any and all liability if this
email transmission was virus corrupted, altered or falsified.
-o-
Astrium Limited, Registered in England and Wales No. 2449259
Registered Office:
Gunnels Wood Road, Stevenage, Hertfordshire, SG1 2AS, England
_______________________________________________
Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu
_______________________________________________
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>