VBR6.5 - Schedule "After this job"

PowerShell script exchange

VBR6.5 - Schedule "After this job"

Veeam Logoby icshoward » Fri Nov 09, 2012 7:10 am

Hi,
You may see there is a new feature about chain execution of jobs in version 6.5. Is there a syntax or command that can modify the option field using powershell?
Thanks.
icshoward
Lurker
 
Posts: 1
Liked: never
Joined: Fri Nov 09, 2012 7:04 am
Full Name: Howard Lee

Re: VBR6.5 - Schedule "After this job"

Veeam Logoby Vitaliy S. » Fri Nov 09, 2012 11:01 am

Hi Howard,

Unfortunately, there is no such command in PowerShell. However, you may want to use the following cmdlet to check current job status and based on the returned result trigger the subsequent backup jobs.

Thanks!
Vitaliy S.
Veeam Software
 
Posts: 19545
Liked: 1099 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: VBR6.5 - Schedule "After this job"

Veeam Logoby v.Eremin » Thu Nov 15, 2012 2:13 pm 2 people like this post

Although, what Vitaliy said was absolutely true, I can propose you some kind of workaround which is able to bypass existing VB&R PowerShell limitations.
What I’m going to represent is:

1)Creation of .bat-file, which consists of PowerShell-commands and which is responsible for starting second, third, whatever number of job in the chain.
2)Specifying this file as a target for Job’s post activity.

I'll show you PowerShell script regarding case of chain execution of only two jobs. However, by the means of simply modifications you can reach whatever scale you want.

First of all, you have to decide where you’re going to store you .bat –file. Say, it’d be D:\Test.bat.
With this knowledge modify Post-activity settings of your first job:

Code: Select all
asnp VeeamPSSnapin
 
$Job = Get-VBRJob | ?{$_.Name –eq “Name of the first job”}
$jo = $job.GetOptions()
$jo.PostJobCommand.Enabled = $True
$jo.PostJobCommand.Commandline = "D:\Test.bat"
$job.SetOptions($jo)


Then write simple PowerShell-script responsible for execution second job in chain:

Code: Select all
asnp VeeamPSSnapin;
$job = Get-VbrJob -name "Name of the second job";
Start-VbrJob -job $job;


Translate it to .bat appropriate format. So, you .bat file should look like this:

Code: Select all
powershell -Command "& {asnp VeeamPSSnapin;$job = Get-VbrJob -name "Name of the second job";Start-VbrJob -job $job;}"


That’s all.

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

Re: VBR6.5 - Schedule "After this job"

Veeam Logoby v.Eremin » Fri Aug 16, 2013 8:08 am

Just want to update the community with the latest information regarding linking jobs through the PowerShell. We’ve fixed previously existing bug with “SetScheduleDependentJobs” method. So, if you’re willing to set a dependent job kindly use the following script:

Code: Select all
Asnp VeeamPSSnapin
$Job1 = Get-VBRJob -name "Name of first job"
$Job2 = Get-VBRJob -name "Name of second job"
$Job2.SetScheduleDependentJobs($Job1)
Set-VBRJobSchedule -Job $Job1 -AfterJob $Job2 


As the result, backup job 2 will be scheduled after Backup Job 1.
Hope this helps.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: VBR6.5 - Schedule "After this job"

Veeam Logoby ghalluin » Tue Aug 12, 2014 8:03 am

Hi

Is the cmdlet SetVbrJobSchedule available in Veeam 6.5.0.109 x64 ?

Because I have an error : cmdlet SetVbrJobSchedule not recognized.
I have already added the snappin Veeam and other cmdlet work properly...

Thanks
ghalluin
Lurker
 
Posts: 1
Liked: never
Joined: Tue Aug 12, 2014 7:33 am

Re: VBR6.5 - Schedule "After this job"

Veeam Logoby v.Eremin » Tue Aug 12, 2014 8:32 am

If my memory serves me well, back at v6.5 days, it was impossible to set dependent job, using PS snap-in, and the only workaround was to use .bat-command. Anyway, you can open a VB&R PS snap-in (Menu -> PowerShell), type Get-VBRCommand and see whether or not the said commandlet is present. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: VBR6.5 - Schedule "After this job"

Veeam Logoby nefes » Tue Aug 12, 2014 8:34 am

Set-VBRJobSchedule was introduced in 7.0
There were Set-VBRJobScheduleOptions in 6.5
You can also check this page to the list of available cmdlets: http://helpcenter.veeam.com/backup/70/powershell/
All cmdlets have an information, were they appear in 7.0 or came from previous versions.
nefes
Veeam Software
 
Posts: 534
Liked: 125 times
Joined: Mon Dec 10, 2012 8:44 am
Full Name: Nikita Efes


Return to PowerShell



Who is online

Users browsing this forum: Exabot [Bot] and 5 guests