10-25-2011 08:33 AM
Hi All,
I am looking to incorporate some script which needs to trigger one batch file at the time of backup begins and once the backup completes "if its a successful backup" then it should trigger an another batch file .
I gone through the guide but i couldn't able to understand properly .
Please let me know how can i do this
Regards,
Rajesh
Solved! Go to Solution.
11-04-2011 08:36 AM
Hi All,
Finally i am able to achive what i wanted , below is the exact script which solved my problem.
:DISK
mountvol J:\Mount_points\DBP /d
diskpart /s "C:\HORCM\Backup_Diskpart\diskpart.txt"
@GOTO :EOF
" Where inturn the diskpart.txt will call diskpart and offline the disk" . And now if and only if the backup status is "0" it is executing other command else not.
One of the main thing what i noticed is we should not give %5 == "0" , correct syntax is %5 == 0 and in the next line we should give @GOTO :EOF else it was executing rest all commands at all the times.
Thanks a lot Mark and Mariane for all your support.
Regards,
Rajesh
10-25-2011 08:42 AM
On the client in the netbackup\bin\ directory you need bpstart_notify.bat and bpend_notify.bat
What ever is in the bpstart one runs before the backup and what ever is in the bpend one runs after the backup
There is a 5 minute timeout for these so if it takes longer than that you need to change the timeout in the client host properties
If you use multiple streams this is not appropriate either as it will run for every stream
#edit# For checking success see the ones in the goodies directory as there are various parameters passed to these so you can adjust them according to the status of the job (status=0 for success)
Hope this helps
10-25-2011 10:56 AM
Hi Mark ,
I got what you mean , but i am unable to understand some points ,
do i need to edit anything on the script ?
Here is my scenario,
1. I will start a backup of one of the client by name " ABC" .
2. Before the backup start it should run a bat file in which in contains " it will make one of the disk online"
3. If the backup completes with "0" then it should run an another bat file which will offline the disk , else if status is "1" then it should rerun the backup.
This is just for example .... in the same way i need to run other scrits on the background.
Regards,
rajesh
10-25-2011 12:40 PM
10-27-2011 11:57 AM
Hi Mark,
I have added the bpstart and bpend_notifiy scripts at netbackup\bin directory and also i have created the output file . Now i am able to see the outpout details on the perticular output file.
I have created a bat file at "C:\Windows\System32\diskpart1.cmd" , in which this bat file will make one of the disk offline .
Can you please tell me where exactly i need to add this so that when once backup completes this bat file has to trigger.
Regards,
Rajesh
10-27-2011 03:33 PM
To take the disk back off line you need to call this script from the bpend_notify.bat script
In thats cript (the sampke one which should be in the goodies directory these days) you will see all of the paramters passed to it from NetBackup
So if you need it to be conditional you nedd to say that if %4 =0 (if that is exit status - done have one to hand at the moment) the run the script
If not conditional then you put in a line that calls that script
dont forget you only get 5 minutes by default for it to work so you need it to wait for the script to have finished before the bpnotify to have done it stuff - i'm sure a scripting guru will help out here
If it takes more than 5 minutes then you can increase the timeout in the tomeouts section of that clients Host properties.
If you run multiple streams thia wont work as it runs both star and end scripts for every stream
Hope this helps
10-28-2011 11:10 AM
Hi,
At the end of the bpend_notify.bat script i have added below mentioned line , but still its not working
if %5 == "0" call "C:\windows\system32\diskpart1.cmd"
Regards,
Rajesh
10-28-2011 12:55 PM
if %5 should be if "%5"
10-28-2011 10:55 PM
Hi,
Below are the details of the bpend_notify.bat script , i want to call a bat file which is stated on the the last line i.e. " "C:\Windows\System32\diskpart1.cmd" when the backup is successful .
But its not working , please let me know what changes need to be made on this script.
@REM $Id: bpend_notify.bat,v 1.3 2006/08/01 20:46:43 $
@REM ***************************************************************************
@REM * $VRTScprght: Copyright 1993 - 2011 Symantec Corporation, All Rights Reserved $ *
@REM ***************************************************************************
@REM ecpyrght
@REM
@REM bpend_notify.bat
@REM
@REM This script is called by NetBackup when bpbkar is finished doing a
@REM backup on the client. It is also called after backing up the files
@REM for a user directed archive, but before the files are deleted.
@REM
@REM This script receives 6 parameters:
@REM %1 = CLIENT_NAME
@REM %2 = POLICY_NAME
@REM %3 = SCHEDULE_NAME
@REM %4 = SCHEDULE_TYPE, one of the following: FULL, INCR, CINC, UBAK, UARC
@REM %5 = Status of backup
@REM %6 = RESULT_FILE
@REM
@REM The script must reside in in the same directory as the rest of the NetBackup
@REM client binaries (install_path\netbackup\bin\bpend_notify.bat).
@REM It must also be executable by the root user.
@REM Should exit with 0 upon successful completion
@REM
@REM Naming conventions:
@REM There are three different versions of names that the scripts can use.
@REM The start notify script may use one version and the end notify script may use
@REM another, or they can both use the same version.
@REM
@REM Substitute "policy" with the NetBackup policy being used and "sched" with the
@REM schedule name. "bpend" can be substituted with "bpstart".
@REM bpend_notify.policy.sched.bat
@REM bpend_notify.policy.bat
@REM bpend_notify.bat
@REM
@REM Result files:
@REM The result file names will be dependant on the script file names.
@REM Example:
@REM Script name: Result file name:
@REM bpstart_notify.policyA.schedB.bat BPSTART_RES.policyA.schedB
@REM bpstart_notify.policyB.bat BPSTART_RES.policyB
@REM bpend_notify.bat BPEND_RES
@REM bpend_notify.policyC.bat BPEND_RES.policyC
@REM
@REM CAUTION: Writing anything to stdout or stderr will cause backup problems.
@REM Output should be redirected to the results files.
@REM
@REM --------------------------------------------------------------------
@REM main script starts here
@REM This is a simple script that records what kind of backup was done along
@REM with other relevent information (Client name, policy name, etc) and
@REM appends the information to the results file
@REM --------------------------------------------------------------------
if "%5" == "0" call "C:\Windows\System32\diskpart1.cmd"
10-30-2011 10:08 PM
HI,
Can any one suggest me on this script where is the problem ?
Regards,
Rajesh
10-30-2011 10:45 PM
Don't use 'call' in the script - just specify full path of the script.
10-31-2011 12:04 AM
Hi Marianne,
Thanks a lot , i have edited the script as below and now i am able to run my custom script.
Is there any way to define the script has to execute only when it is a successful backup when status is "0" , if the status is "1" then it should rerun the backup .
10-31-2011 04:42 AM
Rajesh
From the script above you will see that there is the line 5% = Status of Backup
So you need to add a conditional line saying something to the effect
If 5% = 0 Then Unmount
Else End
[Unmount]
cd "C:\Windows\System32\"
diskpart1.cmd
End
Or similar to what you had initially:
if "%5" == "0" "C:\Windows\System32\diskpart1.cmd"
I'm not the best at scripting but i am sure someone can guide you on the correct syntax
11-03-2011 11:56 PM
HI ,
I tired many options but not able to achive , every time the script is getting executed even the job is failed .
I just want to execute the customized bpend_notify scrity only when the backup is successfully complted (i,.e. when only the status is '0').
Regards,
Rajesh
11-04-2011 02:43 AM
Rajesh
Try this:
if "%5" == "0" goto COMMAND
GOTO :EOF
:COMMAND
C:\Windows\System32\diskpart1.cmd
@REM end of file
11-04-2011 03:52 AM
GOT IT !!
I am no script writer either, but I just had to try for myself.
Created bpend_notify.bat in netbackup\bin on my laptop with only the following 2 lines:
echo "%5" >>c:\temp\junk.txt
if "%5" == "0" "c:\temp\test.bat"
My c:\temp\test.bat had this line:
@echo Backup successful >>c:\temp\junk.txt
After a successful backup I had the following 2 lines in junk.txt:
"0"
Backup successful
I then changed my backup selection to force a status 71.
After the failed backup, my junk.txt looked as follows (note that I am appending to junk.txt each time, meaning that the 2 lines from the 1st backup are still there):
"0"
Backup successful
"71"
Just to really proof that test.back was NOT called, I deleted junk.txt and reran the backup. Result in junk.txt:
"71"
Followed by successful backup without cleaning out junk.txt first:
"71"
"0"
Backup successful
Conclusion?
Only one line is needed in bpend_notify.bat:
if "%5" == "0" "path\script"
11-04-2011 04:18 AM
Marianne - i agree and that is exactly what the last but one line of my post on 31st October says, but Rajesh did say that did not work for him - not sure why - hence my alternative today.
Hopefully one of these will work!
11-04-2011 05:25 AM
I just had to try for my own sanity!
11-04-2011 05:40 AM
Marianne - i do appreciate it - i have always been a physicist and believe that one practical is worth a thousand theories.
11-04-2011 08:32 AM
Great !!
Dont forget to mark a solution to close the thread if you feel that it is appropriate
Glad we have been able to help