Page 1 of 1

Cannot edit backup copy job's schedule via powershell

Posted: Dec 21, 2018 6:18 am
by ta_yoshizumi
Hello all,

I would like to edit bakup copy job's schedule via powershell.
I made a script as follows with reference to other forums.

Code: Select all

asnp VeeamPSSnapin
$job = Get-VBRJob -Name "AD"
$ScheduleOptions = Get-VBRJobScheduleOptions -Job $job
$ScheduleOptions.OptionsBackupWindow.IsEnabled = $false
$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
The process itself ended without any error, and a backup copy job that was valid resulted in a Warning due to the configuration change, and the change of the schedule appeared to be successful.

However, when I checked Edit> Schedule on the Veeam console, it seems that the setting has not been changed.

Please advise if there are known information such as insufficient script syntax or editing of backup copy job can not be confirmed from the GUI.

Thank you for reading.

Re: Cannot edit backup copy job's schedule via powershell

Posted: Dec 21, 2018 10:11 am
by Alex Uryumtsev
Hi,

You forgot to enable Job Schedule. After that your script will change the settings.

Edited code:

Code: Select all

asnp VeeamPSSnapin
$job = Get-VBRJob -Name "AD"
#Enabling job schedule
Enable-VBRJobSchedule -Job $job 
$ScheduleOptions = Get-VBRJobScheduleOptions -Job $job
$ScheduleOptions.OptionsBackupWindow.IsEnabled = $false
$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
If you have any questions left, let me know.

BR,
Alex

Re: Cannot edit backup copy job's schedule via powershell

Posted: Dec 24, 2018 10:50 pm
by ta_yoshizumi
Hello Alex,

Thank you for response my topic.

I added a job valid the code, but there was no change on the GUI.

But "Any time (continuously)" is checked.

Thank you
Takayuki

Re: Cannot edit backup copy job's schedule via powershell

Posted: Dec 25, 2018 7:19 am
by ta_yoshizumi
Hello,

This is additional information.
I ran this code.
In the case of a backup job, the setting can be changed normally, and nothing changes in the case of a backup copy job.

Can this API set backup copy job?

Regards,
Takayuki

Re: Cannot edit backup copy job's schedule via powershell

Posted: Dec 25, 2018 9:33 am
by ta_yoshizumi
Hello Alex,

If you have a sample that how to change the backup copy schedule (setting to restrict transfer time),
Could you show me the code?

Re: Cannot edit backup copy job's schedule via powershell

Posted: Dec 26, 2018 5:09 pm
by Alex Uryumtsev
Hi Takayuki, I am sorry for the mislead.

Here is the code that changes backup copy job schedule:

Code: Select all

Asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Your job"
$options = Get-VBRJobOptions -Job $Job
$ScheduleOptions = $Job.GetScheduleOptions()
#Here you change the option to transfer data during the custom period
$options.joboptions.backupcopyjobcanrunanytime = $false
Set-VBRJobOptions -Job $Job -Options $options
$ScheduleOptions.OptionsContinuous.Schedule = "<scheduler><Sunday>0,0,0,0,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,1,1</Saturday></scheduler>"
Set-VBRJobScheduleOptions -Job $Job -Options $ScheduleOptions
You modify the job schedule by supplying native string format. Then you put 0 and 1 to set desired schedule. I suppose for the one job it would be convenient to make it through gui and then copy native format and populate it to the rest.

BR,
Alex