Editing Backup Windows

PowerShell script exchange

Editing Backup Windows

Veeam Logoby ekisner » Wed May 15, 2013 7:30 pm

So I'm trying to do a bulk update on a number of jobs. Specifically, I'd like to update the schedule and block out some time periods for all jobs.

I can get the jobs:

Code: Select all
$jobs = get-vbrjobs | where {$_.name -like "specific*"}


I can get the schedules:

Code: Select all
get-vbrjobs | where {$_.name -like "specific*"} | foreach-object { $sched = get-vbrjobscheduleoptions; $sched.OptionsPeriodically.Schedule | write-output};


And I could change the schedule (which I see is just a system.string) via set-vbrjobscheduleoptions.

Unfortunately, I can't seem to discern how the schedule works. I see it's an XML string, and that each day has a number of comma-delimited zeros. But, comparing different job schedules to each other doesn't seem to be shedding any light on the matter - I would have expected to see some 1s, or a varying number of zeros... but nothing seems to be different.

If I wanted to block out 10pm to 5am, what would I edit in the string to do so? Since it's the same for all jobs mentioned, I could just enter the string as a variable and just punch that in, rather than editing the existing.
ekisner
Expert
 
Posts: 131
Liked: 31 times
Joined: Thu Jul 26, 2012 8:04 pm
Full Name: Erik Kisner

Re: Editing Backup Windows

Veeam Logoby v.Eremin » Thu May 16, 2013 8:41 am

Could elaborate on it a little bit: do you want to specify allowed backup window and also to terminate the job in case it exceeds allocated period? Or the job is scheduled to run every X minutes/hours and you’re willing to set time interval during which the job shouldn’t be executed?

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

Re: Editing Backup Windows

Veeam Logoby v.Eremin » Thu May 16, 2013 9:03 am 1 person likes this post

Do you want to specify allowed backup window and also to terminate the job in case it exceeds allocated period?

Generally speaking, the BackupWindow parameter is represented by long string containing days of the week, as well as, numbers. There are 24 (hours) numbers between each pair of the days. Number might be either 1, if the job run is denied during it, or 0, if it’s allowed.

For instance, the following script will set a backup window(0-4, Sunday). The job exceeding it should be termitated:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your Job"
$ScheduleOptions = $Job.GetScheduleOptions()
$ScheduleOptions.OptionsBackupWindow.Isenabled = $True
$ScheduleOptions.OptionsBackupWindow.BackupWindow = "<scheduler><Sunday>1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Sunday><Monday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Monday><Tuesday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Tuesday><Wednesday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Wednesday><Thursday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Thursday><Friday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Friday><Saturday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Saturday></scheduler>"
Set-VBRJobScheduleOptions -job $Job -Options $ScheduleOptions


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

Re: Editing Backup Windows

Veeam Logoby ekisner » Thu May 16, 2013 3:52 pm

Thank you v.Eremin!

Specifically, I don't need to terminate a job outside of the window, I just want to prevent one from starting outside of the allowable time period.
ekisner
Expert
 
Posts: 131
Liked: 31 times
Joined: Thu Jul 26, 2012 8:04 pm
Full Name: Erik Kisner

Re: Editing Backup Windows

Veeam Logoby v.Eremin » Fri May 17, 2013 12:00 pm

Ok, I’ve got you point. In general, there are two quite similar scripts.

This one will specify the so-called "allowed" backup window. If a job exceeds allocated period, it will be terminated. This script should be used if one of the following options is ticked: Run the job automatically daily at this time, monthly at this time.

The following example has a time interval between 0 and 4 am, Sunday, as a backup window:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your Job"
$ScheduleOptions = $Job.GetScheduleOptions()
$ScheduleOptions.OptionsBackupWindow.Isenabled = $True
$ScheduleOptions.OptionsBackupWindow.BackupWindow = "<scheduler><Sunday>1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Sunday><Monday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Monday><Tuesday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Tuesday><Wednesday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Wednesday><Thursday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Thursday><Friday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Friday><Saturday>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Saturday></scheduler>"
Set-VBRJobScheduleOptions -job $Job -Options $ScheduleOptions


The other one will set a window during whcih execution of a given job will be prohibited (22 00 – 05 00, all days). It should be used if "Run the job automatically periodically" option is enabled:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your job"
$ScheduleOptions = $Job.GetScheduleOptions()
$ScheduleOptions.OptionsPeriodically.schedule = "<scheduler><Sunday>1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1</Sunday><Monday>1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1</Monday><Tuesday>1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1</Tuesday><Wednesday>1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1</Wednesday><Thursday>1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1</Thursday><Friday>1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1</Friday><Saturday>1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1</Saturday></scheduler>"
Set-VBRJobScheduleOptions -job $Job -Options $ScheduleOptions


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

[MERGED] : Changing time window for multiple jobs

Veeam Logoby marius roma » Mon Dec 07, 2015 4:23 pm

I have many jobs with time windows so, for example, they cannot run from Monday to Friday from 8:00 AM to 8:00 PM.
They can run instead on Saturday and Sunday.
This is a standard time window and is ok.
Given that fow a given week a week day (let's say Tuesday) is bank holiday, is there a way to change the time window for all my jobs so that jobs can run on Tuesday for the next week and change again the time window for all my hob when the bank holiday is over to re-establish the standard time window?
Regards
marius
marius roma
Expert
 
Posts: 317
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: Editing Backup Windows

Veeam Logoby v.Eremin » Mon Dec 07, 2015 5:51 pm

You can modify the script provided above in order for it to change the said settings for multiple jobs, instead for single one. Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 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 3 guests