Setting Backup Window Options

PowerShell script exchange

Setting Backup Window Options

Veeam Logoby DaveWatkins » Thu Jun 09, 2016 8:58 pm

Hi All

I'm trying to specify a backup window on a job but can't work out how to bind the options I set with

Set-VBRBackupWindowOptions

to an actual job. All the other cmdlets have a -Job parameter or you can pipe in a job, but this doesn't appear to be the case with this one.

Can someone give me a quick example of how to set a Backup Window for a job?

Thanks
DaveWatkins
Expert
 
Posts: 252
Liked: 61 times
Joined: Sun Dec 13, 2015 11:33 pm

Re: Setting Backup Window Options

Veeam Logoby DaveWatkins » Thu Jun 09, 2016 9:55 pm

Ok, so in the interests of someone else not running into this you need to do something like this

Code: Select all
$job = Get-VBRJob -Name <name>
$ScheduleOptions = Get-VBRJobScheduleOptions -Job $job
$ScheduleOptions.OptionsBackupWindow = New-VBRBackupWindowOptions -FromDay "Saturday" -FromHour 4 -ToDay "Saturday" -ToHour 23 -Enabled:$False
Set-VBRJobScheduleOptions -Job $job -Options $ScheduleOptions


However, what I really want is to block out a window from 4am Saturday to 4am Sunday but using those values instead blocks out the 4am-5am block across every day of the week :/

I can only assume I have set these one day at a time and use Set-VBRBackupWindowOptions but I've yet to even get that to work so, as soon as I try and use Set-VBRBackupWindowOptions on an already created object I end up with no backup Window set.

So, back to the original question, how to a block out period in a backup window that spans 24 hours from 4am on Saturday to 4am on Sunday?
DaveWatkins
Expert
 
Posts: 252
Liked: 61 times
Joined: Sun Dec 13, 2015 11:33 pm

Re: Setting Backup Window Options

Veeam Logoby DaveWatkins » Tue Jun 14, 2016 8:23 pm

Anyone?

Even if someone could just confirm what I'm seeing so I can log it as a bug. This code blocks out a 1 hour period for every day of the week, when it should, as far as I can tell, block out a 24 hour period from 4am Saturday to 4am Sunday

Code: Select all
$job = Get-VBRJob -Name <name>
$ScheduleOptions = Get-VBRJobScheduleOptions -Job $job
$ScheduleOptions.OptionsBackupWindow = New-VBRBackupWindowOptions -FromDay Saturday -FromHour 4 -ToDay Sunday -ToHour 4 -Enabled:$False
Set-VBRJobScheduleOptions -Job $job -Options $ScheduleOptions


Thanks
DaveWatkins
Expert
 
Posts: 252
Liked: 61 times
Joined: Sun Dec 13, 2015 11:33 pm

Re: Setting Backup Window Options

Veeam Logoby v.Eremin » Tue Jun 21, 2016 1:26 pm

Try the following approach and see whether it meets your expectations:

Code: Select all
asnp VeeamPSSnapin
$job = Get-VBRJob -Name "Name of your job"
$schedule = Get-VBRJobScheduleOptions -Job $job

$options = New-VBRBackupWindowOptions -FromDay Saturday -FromHour 0 -ToDay Sunday -ToHour 23 -Enabled:$true
$options = Set-VBRBackupWindowOptions -Options $options -PassThru -FromDay Sunday -FromHour 0 -ToDay Sunday -ToHour 3 -Enabled:$false
$options = Set-VBRBackupWindowOptions -Options $options -PassThru -FromDay Saturday -FromHour 4 -ToDay Saturday -ToHour 23 -Enabled:$false

$schedule.OptionsBackupWindow = $options

Set-VBRJobScheduleOptions -Job $job -Options $schedule

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

Re: Setting Backup Window Options

Veeam Logoby DaveWatkins » Tue Jun 21, 2016 8:15 pm

That worked, thanks.

One final question, how do you then disable the Backup Window entirely? At the moment I'm just setting it to tru for the entire week but I'd prefer to be able to remove the tickbox itself and disable it outright.

Thanks
DaveWatkins
Expert
 
Posts: 252
Liked: 61 times
Joined: Sun Dec 13, 2015 11:33 pm

Re: Setting Backup Window Options

Veeam Logoby v.Eremin » Wed Jun 22, 2016 8:51 am

You should modify the value of IsEnabled parameter in the following manner:

Code: Select all
asnp VeeamPSSnapin
$job = Get-VBRJob -Name "Name of your Job"
$ScheduleOptions = Get-VBRJobScheduleOptions -Job $job
$ScheduleOptions.OptionsBackupWindow.IsEnabled = $false
Set-VBRJobScheduleOptions -Job $job -Options $ScheduleOptions


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


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests