PowerShell script exchange
Post Reply
DaveWatkins
Veteran
Posts: 370
Liked: 97 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Setting Backup Window Options

Post by DaveWatkins »

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
Veteran
Posts: 370
Liked: 97 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Re: Setting Backup Window Options

Post by DaveWatkins »

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
Veteran
Posts: 370
Liked: 97 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Re: Setting Backup Window Options

Post by DaveWatkins »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Setting Backup Window Options

Post by veremin »

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.
DaveWatkins
Veteran
Posts: 370
Liked: 97 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Re: Setting Backup Window Options

Post by DaveWatkins »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Setting Backup Window Options

Post by veremin »

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.
jmertensnetuk
Service Provider
Posts: 46
Liked: 13 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

[MERGED] Change existing backup window for all backup jobs

Post by jmertensnetuk »

My goal: To gather all jobs with JobType = Backup and set the backup window to 8AM-8PM every day between Monday and Friday

However I am falling at the first hurdle regarding Set-VBRBackupWindowOptions

It says that -Options is required but I am not sure what value to put into here?

Also for the gathering of all jobs with type backup I am using the below:

$Job = Get-VBRJob | where {$_.JobType -eq "Backup"}
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Setting Backup Window Options

Post by veremin »

Check the examples above and see whether they answer your requirements. Thanks!
jmertensnetuk
Service Provider
Posts: 46
Liked: 13 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

Re: Setting Backup Window Options

Post by jmertensnetuk »

Hi veremin ,

I think I am looking at the wrong setting as the above examples change values in the "Backup Window"

Whereas I actually want to change the values in the "Schedule.." tab next to the "Periodically every: 2 hours" for example.

When opened in the UI the "Schdule.." tab has the title of "Time Periods"

On the reference page I can't find a cmdlet that manages this
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Setting Backup Window Options

Post by jhoughes »

You should look at example 3 on the 'Set-VBRJobSchedule' cmdlet page for this; you're needing to leverage the 'Periodicaly' and 'PeriodicallyKind' parameters.

https://helpcenter.veeam.com/docs/backu ... l?ver=95u4
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
jmertensnetuk
Service Provider
Posts: 46
Liked: 13 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

Re: Setting Backup Window Options

Post by jmertensnetuk » 1 person likes this post

Ok thank you, the below seems to do what I want:

Code: Select all

asnp VeeamPSSnapin
$windowoptions = New-VBRBackupWindowOptions -FromDay Monday -FromHour 8 -ToDay Friday -ToHour 19 -Enabled
Get-VBRJob | where {$_.JobType -eq "Backup"} | Set-VBRJobSchedule -Periodicaly -FullPeriod 2 -PeriodicallyKind Hours -PeriodicallySchedule $windowoptions
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests