Script/Command that will suspend all Active jobs for Client @ 7:00am

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

1 Solution

Accepted Solutions
Highlighted
Accepted Solution!

OK - it wasn't quite as bad

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

View solution in original post

15 Replies
Highlighted

Put this in a bat

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)

Highlighted

so would you like to suspend

so would you like to suspend the jobs for specific client?

any reason why you are looking for specific client?

Highlighted

NetBackup de-activate

Highlighted

Thanks Guys, Thanks for the

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

Highlighted

Not so easy to do it that way

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

Highlighted
Accepted Solution!

OK - it wasn't quite as bad

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

View solution in original post

Highlighted

....or put the specific

....or put the specific client in its own policy

Highlighted

Stumpr2 .. he wants to

Stumpr2 .. he wants to suspend running jobs at 7am and then resume them at 10pm - not just stop policies running

Highlighted

I just ran into a need for

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!

Highlighted

Big Thanks Mark, I appreciate

Big Thanks Mark,

I appreciate your time on this.

John

Highlighted

Also to other

Also to other contributors

Thanks,

 

John

Highlighted

No problem - i enjoy the

No problem - i enjoy the challenge!!

Highlighted

Re: I just ran into a need for

This is very helpful for us as this is applicable for one client only.

can you please help on this script for multiple servers

Highlighted

Re: I just ran into a need for

 

Please start a new discussion for your query? 
Most of the users in this thread are no longer on VOX. 

 

Highlighted
Moved:

Re: I just ran into a need for