03-20-2014 10:02 AM
Hi There,
Anyone know of a script or command that exists that would enable me to suspend all active jobs for Netbackup client @ 7:00am and then resume them at 10pm?
I have looked at bpdbjobs and found that I can suspend via
-suspend xxxxxxx
but as I would like this script to be scheduled I require something that will
-suspend * -client myclent
Any ideas appreciated.
John
Solved! Go to Solution.
03-21-2014 05:09 AM
OK - it wasn't quite as bad as i thought!!
So here you go .. these assume that we make a directory on the Master Server named C:\suspendjobs\ and in there we make three files, suspend.bat, check.vbs and resume.bat.
It also assumes that your environment variables are setup so /netbackup/bin/admincmd/ is in your path, if not edit these to add in the full paths remembering to use quotes around them if there are any spaces (so "C:\Program Files\veritas\netbackup\bin\admincmd\bpdbjobs" -report)
It also assumes that your clients name is server1 - so change that in the scripts.
Windows scheduler will then run suspend.bat at 7am and resume.bat at 10pm
So the contents need to be:
suspend.bat:
del /Q c:\suspendjobs\runningjobs.txt
bpdbjobs -report -all_columns -ignore_parent_jobs> c:\suspendjobs\alljobs.txt
c:\suspendjobs\check.vbs
for /f %%a in (c:\suspendjobs\runningjobs.txt) do bpdbjobs -suspend %%a -quiet
check.vbs:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\suspendjobs\alljobs.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrFields = Split(strLine,",")
If InStr(arrFields(6), "server1") And InStr(arrFields(3), "")<=0 Then
strContents = strContents & arrFields(0) & vbCrlf
End If
Loop
objFile.Close
Set objFile = objFSO.CreateTextFile("c:\suspendjobs\runningjobs.txt")
objFile.Write strContentsa
objFile.Write strContents
objFile.Close
resume.bat:
for /f %%a in (c:\suspendjobs\runningjobs.txt) do bpdbjobs -resume %%a -quiet
03-20-2014 10:21 AM
Put this in a bat file:
bpdbjobs -suspend type=all -quiet
and have windows scheduler run it at 7am
In another bat file put:
bpdbjobs -resume type=all -quiet
and have Windows scheduler run that at 10pm
Only certain types of jobs can be suspended though (file system jobs with checkpoint re-start)
03-20-2014 10:26 AM
so would you like to suspend the jobs for specific client?
any reason why you are looking for specific client?
03-20-2014 10:57 AM
NetBackup de-activate specific policies during business hours
03-20-2014 12:06 PM
Thanks Guys,
Thanks for the suggestions. But my issue is client specific.
We have a high profile client job split into multiple streams.
Some streams do not complete in their backup window, sometimes running over a couple of days.
We are required to let these jobs run to completion but cannot allow them to run during PROD hours.
So we are manually suspending jobs at 7am and then resuming them when the window opens @ 10pm.
Looking for a way to automate suspend/resume currently running jobs.
Thanks,
John
03-21-2014 03:10 AM
Not so easy to do it that way - we need to query NetBackup to get a lits of job ID's for the client and then run the suspend command against those.
You would still use the Windows scheduler to do the work for you and 2 .bat files should do what you need but you will probably need a little vbs adding in there too. The vbs needs to read the alljobs.txt file and pipe out the job id for all jobs with no status column for you client and write that to an activejobs.txt file.
So first one, suspend.bat, needs to contain:
del /Q activejobs.txt
bpdbjobs -report > c:\alljobs.txt
check.vbs
for /f in (activejobs.txt) do bpdbjobs -suspend %%a -quiet
The second one, resume.bat, will contain:
for /f in (activejobs.txt) do bpdbjobs -resume %%a -quiet
If you keep a lot of jobs in activity monitor these could take some time to actually run
If i get chance I will have a crack at the vbs script needed
03-21-2014 05:09 AM
OK - it wasn't quite as bad as i thought!!
So here you go .. these assume that we make a directory on the Master Server named C:\suspendjobs\ and in there we make three files, suspend.bat, check.vbs and resume.bat.
It also assumes that your environment variables are setup so /netbackup/bin/admincmd/ is in your path, if not edit these to add in the full paths remembering to use quotes around them if there are any spaces (so "C:\Program Files\veritas\netbackup\bin\admincmd\bpdbjobs" -report)
It also assumes that your clients name is server1 - so change that in the scripts.
Windows scheduler will then run suspend.bat at 7am and resume.bat at 10pm
So the contents need to be:
suspend.bat:
del /Q c:\suspendjobs\runningjobs.txt
bpdbjobs -report -all_columns -ignore_parent_jobs> c:\suspendjobs\alljobs.txt
c:\suspendjobs\check.vbs
for /f %%a in (c:\suspendjobs\runningjobs.txt) do bpdbjobs -suspend %%a -quiet
check.vbs:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\suspendjobs\alljobs.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrFields = Split(strLine,",")
If InStr(arrFields(6), "server1") And InStr(arrFields(3), "")<=0 Then
strContents = strContents & arrFields(0) & vbCrlf
End If
Loop
objFile.Close
Set objFile = objFSO.CreateTextFile("c:\suspendjobs\runningjobs.txt")
objFile.Write strContentsa
objFile.Write strContents
objFile.Close
resume.bat:
for /f %%a in (c:\suspendjobs\runningjobs.txt) do bpdbjobs -resume %%a -quiet
03-21-2014 06:12 AM
....or put the specific client in its own policy
03-21-2014 06:17 AM
Stumpr2 .. he wants to suspend running jobs at 7am and then resume them at 10pm - not just stop policies running
03-24-2014 03:48 PM
I just ran into a need for this today and you don't know how much time you just saved me by posting this. Thank you!
Also, with a just a few simple changes in the vbs script you can suspend multiple jobs based on a unique string in the policy name!
03-25-2014 05:17 AM
Big Thanks Mark,
I appreciate your time on this.
John
03-25-2014 05:17 AM
Also to other contributors
Thanks,
John
03-25-2014 06:09 AM
No problem - i enjoy the challenge!!
12-14-2017 03:06 AM
This is very helpful for us as this is applicable for one client only.
can you please help on this script for multiple servers
12-14-2017 03:14 AM - edited 12-14-2017 03:17 AM
Please start a new discussion for your query?
Most of the users in this thread are no longer on VOX.
12-14-2017 05:19 AM