PowerShell script exchange
Post Reply
ta_yoshizumi
Enthusiast
Posts: 62
Liked: 3 times
Joined: Jun 18, 2018 12:29 am
Contact:

Cannot edit backup copy job's schedule via powershell

Post 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.
Alex Uryumtsev
Enthusiast
Posts: 51
Liked: 7 times
Joined: Oct 29, 2018 9:56 am
Full Name: Alexander Uryumtsev
Contact:

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

Post 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
ta_yoshizumi
Enthusiast
Posts: 62
Liked: 3 times
Joined: Jun 18, 2018 12:29 am
Contact:

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

Post 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
ta_yoshizumi
Enthusiast
Posts: 62
Liked: 3 times
Joined: Jun 18, 2018 12:29 am
Contact:

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

Post 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
ta_yoshizumi
Enthusiast
Posts: 62
Liked: 3 times
Joined: Jun 18, 2018 12:29 am
Contact:

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

Post 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?
Alex Uryumtsev
Enthusiast
Posts: 51
Liked: 7 times
Joined: Oct 29, 2018 9:56 am
Full Name: Alexander Uryumtsev
Contact:

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

Post 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
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 9 guests