PowerShell script exchange
Post Reply
DaveWatkins
Expert
Posts: 346
Liked: 92 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Setting Backup Window Options

Post by DaveWatkins » 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: 346
Liked: 92 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Re: Setting Backup Window Options

Post by DaveWatkins » 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: 346
Liked: 92 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Re: Setting Backup Window Options

Post by DaveWatkins » 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

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Setting Backup Window Options

Post by veremin » 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.

DaveWatkins
Expert
Posts: 346
Liked: 92 times
Joined: Dec 13, 2015 11:33 pm
Contact:

Re: Setting Backup Window Options

Post by DaveWatkins » 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

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Setting Backup Window Options

Post by veremin » 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.

jmertensnetuk
Service Provider
Posts: 40
Liked: 12 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 » Aug 02, 2019 10:26 am

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: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Setting Backup Window Options

Post by veremin » Aug 02, 2019 10:58 am

Check the examples above and see whether they answer your requirements. Thanks!

jmertensnetuk
Service Provider
Posts: 40
Liked: 12 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

Re: Setting Backup Window Options

Post by jmertensnetuk » Aug 05, 2019 1:39 pm

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 Software
Posts: 91
Liked: 21 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Setting Backup Window Options

Post by jhoughes » Aug 05, 2019 1:46 pm

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 Extraordinaire | @AustinVMUG & @ATXPowerShell leader | vExpert | Cisco Champion | Tech Field Day Delegate | VCP 4/5/6 | VCP6-NV | VMware/Cisco UCS/Powershell/VEEAM Enthusiast

jmertensnetuk
Service Provider
Posts: 40
Liked: 12 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

Re: Setting Backup Window Options

Post by jmertensnetuk » Aug 05, 2019 2:19 pm 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 3 guests