Check if another job is chained after this one?

PowerShell script exchange

Check if another job is chained after this one?

Veeam Logoby pkelly_sts » Tue Jun 14, 2016 2:25 pm

Is it possible, with Powershell in a post-job script, to check whether there is another Tape job scheduled/chained to run after the currently running/finishing job (the one calling the post-job script)?

Basically I only want the main part of the post-job script to run (stopping BExec services on the tape server) if there isn't another, specific, Veeam tape job scheduled to run right after it? Just wanting to avoid restarting the BExec services only to stop them all again 1 min later.

I'm being a little fussy I guess but it's useful powershell scripting experience anyway :)
[New Sig: PLEASE get GFS tape support for incrementals!!!]
pkelly_sts
Expert
 
Posts: 504
Liked: 55 times
Joined: Thu Jun 13, 2013 10:08 am
Full Name: Paul Kelly

Re: Check if another job is chained after this one?

Veeam Logoby pkelly_sts » Tue Jun 14, 2016 2:41 pm 1 person likes this post

Reading through the forums I just found this bit of code which I think I can make use of and led me to find the "ScheduleOptions" property of "AfterJob", but a quick test reveals that this property remains even if the job is disabled so now I need to detect whether the job is AfterJob AND disabled...
[New Sig: PLEASE get GFS tape support for incrementals!!!]
pkelly_sts
Expert
 
Posts: 504
Liked: 55 times
Joined: Thu Jun 13, 2013 10:08 am
Full Name: Paul Kelly

Re: Check if another job is chained after this one?

Veeam Logoby v.Eremin » Tue Jun 21, 2016 10:28 am

That's the easiest way to check whether a given tape job is enabled or not:

Code: Select all
Asnp VeeamPSSnapin
$TapeJob = Get-VBRTapeJob -Name "Name of your tape job"
$TapeJob.ScheduleOptions.Enabled

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Check if another job is chained after this one?

Veeam Logoby pkelly_sts » Tue Jun 21, 2016 2:38 pm

Thanks, but just knowing a job is enabled isn't quite enough.

A little more detail:

I run two tape jobs to a tape server that also runs BAckup exec (until I'm confident enough to switch to Veeam)

To run a veeam tape job I need to stop BExec services so have written a PRE-JOB script to check if there are any active BExec jobs and, if not, stop the services, otherwise check again in 5 mins, up to an hour)

I also have a POST-JOB script that starts the BExec services again after the Veeam tape job.

All of this works fine, but because I have 2 tape jobs and they must be run in serial (because only 1 tape drive available) I run the second job right after the first job.

So, it would save me a little time, plus be a bit more efficient, if I could know that the second job was chained to the first so I could build logic into the POST-JOB script to say "if there are no other jobs chained to this one, start the services again, otherwise leave them stopped. (Note: my PRE-JOB script only stops running services anyway)

I want to build in this intelligence in case I later run the second job under its own schedule rather than chained, in which case the first job will automatically restart the services when completed.

Hopefully this makes sense?

(It has also been a learning exercise with Powershell which I just don't do much of these days so want to keep my hand in...)
[New Sig: PLEASE get GFS tape support for incrementals!!!]
pkelly_sts
Expert
 
Posts: 504
Liked: 55 times
Joined: Thu Jun 13, 2013 10:08 am
Full Name: Paul Kelly


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 2 guests