PowerShell script exchange
Post Reply
jb303uk
Novice
Posts: 7
Liked: never
Joined: Feb 11, 2015 11:27 am
Contact:

Backup Copy Job Advanced Options (Add-VBRViBackupCopyJob)

Post by jb303uk »

Hi,
I was wondering if anyone could help, I'm trying to create a Backup Copy job using powershell but the documentation only references basic settings (for Add-VBRViBackupCopyJob http://helpcenter.veeam.com/backup/80/p ... pyjob.html).
Is there a way to alter settings such as:
  • Number of backups to keep for Archival purposes eg: Keep 12 Monthly backups & 7 Yearly backups
    When the Full backups happen (eg Last Friday of the Week/Month/Quarter/Year)
    Number of Restore points to keep
Hope someone can help!

Thanks
James
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Copy Job Advanced Options (Add-VBRViBackupCopyJob

Post by veremin »

Most of settings of backup copy job can be configured in the following way:

Code: Select all

$BCJ = Get-VBRJob -name "Name of your backup copy job"
$Options = $BCJ.GetOptions()
$Options.GenerationPolicy 
#Change those however you like
$BCJ.SetOptions($Options)
GenerationPolicy contains the following settings.

Image

Thanks.
jb303uk
Novice
Posts: 7
Liked: never
Joined: Feb 11, 2015 11:27 am
Contact:

Re: Backup Copy Job Advanced Options (Add-VBRViBackupCopyJob

Post by jb303uk »

Hi,
Thankyou for your help, I have managed to change these settings via Powershell thankyou, however (rather embarrassingly) I can't get the tick box 'Keep the following restore points for archival purposes' to be ticked :oops:
Image
Can you solve my last piece of the puzzle?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Copy Job Advanced Options (Add-VBRViBackupCopyJob

Post by veremin » 1 person likes this post

You should play with RetentionPolicyType parameter, change its value from "simple" to something like "GFS" (need to check that, as currently I don't have access to a console). Thanks.
jb303uk
Novice
Posts: 7
Liked: never
Joined: Feb 11, 2015 11:27 am
Contact:

Re: Backup Copy Job Advanced Options (Add-VBRViBackupCopyJob

Post by jb303uk »

v.Eremin wrote:You should play with RetentionPolicyType parameter, change its value from "simple" to something like "GFS" (need to check that, as currently I don't have access to a console). Thanks.
Bingo thats it no need to check!
Here's the code I used

Code: Select all

$ArcJobObj = Get-VBRJob -name "My Job X";  
$Options = $ArcJobObj.GetOptions();
$options.GenerationPolicy.RetentionPolicyType = "GFS";
$ArcJobObj.SetOptions($Options);
$Options.GenerationPolicy;
Thankyou for your help

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

Re: Backup Copy Job Advanced Options (Add-VBRViBackupCopyJob

Post by veremin »

Glad to hear that you've nailed it. By the way, the last string doesn't serve any practical use apart from showing the updated backup copy job settings, so, you might want to remove it completely. Thanks.
twesterd
Influencer
Posts: 17
Liked: 3 times
Joined: May 17, 2017 7:38 pm
Full Name: Trevor W
Contact:

[MERGED] Change options for a Backup Copy job

Post by twesterd »

I am still new to PowerShell with Veeam and my first impression is that the documentation doesn't include the objects/properties related to each command. This makes for a lot of hunting around. In Visual Studio, I add the Veeam dll references and can cast the objects to the correct types and that helps substantially. In PowerShell, I can display an object as output in the console, or otherwise use the get-members command and hunt around that way.

I thought it might be helpful to provide a sample of changing the commonly configured properties for a Backup Copy job. In my use-case, all copy jobs are GFS (grandfather, father, son). So, this example related to GFS jobs and their settings. You should be able to insert the correct Backup Copy job's name and the snippet should work. Change values and you can then associate which property matches which item in the GUI. I clone a job in the GUI, leave it disabled, and play around with settings to match properties to screen values. Hopefully, it helps someone. Took me a while to put all of these together as I didn't even know to look in the GenerationPolicy selection.

Sample below:

Code: Select all

$Job = Get-VBRJob -Name 'Template Backup Copy Jobs'
$Options = $Job.GetOptions()
$Options.GenerationPolicy.RetentionPolicyType = 'GFS'
$Options.GenerationPolicy.GFSWeeklyBackups = 1
$Options.GenerationPolicy.GFSMonthlyBackups = 2
$Options.GenerationPolicy.GFSQuarterlyBackups = 3
$Options.GenerationPolicy.GFSYearlyBackups = 4
$Options.GenerationPolicy.EnableRechek = $True
$Options.GenerationPolicy.RecheckDays = [System.DayOfWeek] 'Friday', 'Monday'
$Options.GenerationPolicy.RecheckScheduleKind = 'Monthly'
$Options.GenerationPolicy.SyncIntervalStartTime = '14:30:00'
$Options.GenerationPolicy.SimpleRetentionRestorePoints = 14
$Options.GenerationPolicy.WeeklyBackupDayOfWeek = 'Thursday'
$Options.GenerationPolicy.WeeklyBackupTime = '19:15:00'
$Options.GenerationPolicy.RecoveryPointObjectiveUnit = 'Day'
$Options.GenerationPolicy.RecoveryPointObjectiveValue = 1
$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = 'Third'
$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = 'Wednesday'
$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.Months = [Veeam.Backup.Common.Emonth] 'January', 'February'
$Job.SetOptions($Options)
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests