PowerShell script exchange
Post Reply
dbr
Expert
Posts: 118
Liked: 16 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Change interval time of backup copy job via powershell

Post by dbr »

Hi all,

I would like to script creation of our backup and backup copy jobs cause of job redesign. I'm struggeling with changing the default interval time from 00:00 to 18:00 in a backup copy job. It's easy for a backup job: Set-VBRJobSchedule -Job <backupjobname> -daily -at 18:00. But I couldn't find a suiteable cmdlet or any other way to set the interval time of a copy job. Set-VBRJobSchedule doesn't seem to work with backup copy jobs.

Error:

Code: Select all

Set-VBRJobSchedule : Specify a backup job
At line:1 char:1
+ Set-VBRJobSchedule -Job se-bc-62 -daily -at 18:00
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-VBRJobSchedule], Exception
    + FullyQualifiedErrorId : System.Exception,Veeam.Backup.PowerShell.Cmdlets.SetVBRJobSchedule
Does anyone know how to change interval time through powershell?

Daniel
dbr
Expert
Posts: 118
Liked: 16 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Change interval time of backup copy job via powershell

Post by dbr »

I figured out the solution by myself:

Code: Select all

$timespan = new-timespan -hours 18
$joboptions = get-vbrjoboptions -job se-bc-62
$joboptions.GenerationPolicy.SyncIntervalStartTime = $timespan
set-vbrjoboptions -job se-bc-62 -options $joboptions
Thanks.
shanewendel
Novice
Posts: 3
Liked: never
Joined: Jan 29, 2019 5:45 pm
Full Name: Shane Wendel
Contact:

Re: Change interval time of backup copy job via powershell

Post by shanewendel »

This code doesn't quite work because that isn't the proper settings variable

This is the correct code to change the interval:

Code: Select all

#Ensure the Copy Interval is set to 1 hour
$joboptions = get-vbrjoboptions -job "Backup Copy Job"
$joboptions.GenerationPolicy.RecoveryPointObjectiveUnit = "Hour"
$joboptions.GenerationPolicy.RecoveryPointObjectiveValue = 1
set-vbrjoboptions -job "Backup Copy Job" -options $joboptions
dbr
Expert
Posts: 118
Liked: 16 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Change interval time of backup copy job via powershell

Post by dbr »

I guess your code works well if you want to change the interval type e.g. from daily to hourly. My original demand was only to set the interval start time to a different time (00:00 to 18:00) while keeping interval type. So my code works as well for interval type daily.
jbcap
Influencer
Posts: 18
Liked: never
Joined: May 24, 2018 4:12 am
Full Name: Jim Bell
Contact:

Re: Change interval time of backup copy job via powershell

Post by jbcap »

If you have multiple jobs to set:

Code: Select all

$copyjobs = Get-VBRJob | where TypeToString -match copy
$joboptions = get-vbrjoboptions -job $copyjobs[0]
$joboptions.GenerationPolicy.SyncIntervalStartTime = New-TimeSpan -Hours 01

foreach ($i in $copyjobs) {
    $job = $i.LogNameMainPart
    Set-VBRJobOptions -Job $job -Options $joboptions
}
csmatthews
Lurker
Posts: 2
Liked: never
Joined: Sep 18, 2020 3:04 pm
Full Name: Christopher Matthews
Contact:

[MERGED] Change Monthly Day on Copy Job

Post by csmatthews »

The company I work for has an EOM that changes each month, This month EOM is the 27th next month EOM isn't until November 1st.

I am trying to write a powershell script to update all of my copy jobs "Monthly Backup" Date.


This is what I have, but I can't get it to work for one job so I haven't tried modifying it for multiple jobs.

Code: Select all

$Job = Get-VBRJob -Name "Job Name Here*"
Set-VBRJobSchedule -Job $Job -NumberInMonth OnDay -DayOfMonth 27

Error Message:
Set-VBRJobSchedule : Specify a backup job
At line:18 char:1
+ Set-VBRJobSchedule -Job $Job -NumberInMonth OnDay -DayOfMonth 28
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-VBRJobSchedule], Exception
    + FullyQualifiedErrorId : System.Exception,Veeam.Backup.PowerShell.Cmdlets.SetVBRJobSchedule
When I look at the $Job variable it has the job I searched for with Get-VBRJob. So I am guessing the Set-VBRJobSchedule only works with backups and not backup copy jobs. I haven't been able to find a command from the list to set this. Any help would be appreciated.

Thank you
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Change interval time of backup copy job via powershell

Post by Natalia Lupacheva »

Hi Christopher,

thank you for the detailed description of the issue you've faced.
I've moved your post to the existing thread, please take a look at the suggestions here, might give you a hint.

Thanks!
csmatthews
Lurker
Posts: 2
Liked: never
Joined: Sep 18, 2020 3:04 pm
Full Name: Christopher Matthews
Contact:

Re: Change interval time of backup copy job via powershell

Post by csmatthews »

I will check out the suggestions here but my problem is different. I want to change the day of month it creates the Monthly back up
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change interval time of backup copy job via powershell

Post by oleg.feoktistov »

Hi @csmatthews,
When I look at the $Job variable it has the job I searched for with Get-VBRJob. So I am guessing the Set-VBRJobSchedule only works with backups and not backup copy jobs. I haven't been able to find a command from the list to set this. Any help would be appreciated.
I'm not quite sure I got you right, because in terms of backup copy job there are intervals (copy every ... minutes/hours/days) and data transfer window.
The feature you ask for is more relevant to backup jobs. Can you, please, elaborate on what you mean?
Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests