PowerShell script exchange
Post Reply
Miha Pecnik
Novice
Posts: 5
Liked: 1 time
Joined: Feb 16, 2025 12:16 pm
Full Name: Miha Pecnik
Contact:

Creating backup jobs with PowerShell

Post by Miha Pecnik »

We're trying to automate the creating of backup jobs, with all the settings, so far we've got this which works:

Code: Select all

$Repository = "Repo1"
$Vm = Find-VBRHvEntity -Name "VM1"
$job = Add-VBRHvBackupJob -Name "Critical" -Description "Backup job for critical VMs" -BackupRepository $Repository -Entity $Vm
$jobOptions = Get-VBRJobOptions -Job $job
$jobOptions.BackupTargetOptions.Algorithm = "Increment"
Set-VBRJobOptions -Job $job -Options $jobOptions
But we need to:
1. Use on-host backup proxy and I can't find a setting for that.
2. We need to configure the retention policy, GFS, but are failing:

Code: Select all

# Create GFS options
$weeklyGFS = New-VBRGFSWeeklyOptions -RetentionPeriod 4 -SelectedDay Sunday
$monthlyGFS = New-VBRGFSMonthlyOptions -RetentionPeriod 12 -SelectedWeek First
$yearlyGFS = New-VBRGFSYearlyOptions -RetentionPeriod 2 -SelectedMonth January

# Combine GFS options into a policy
$gfsOptions = New-VBRGFSOptions -WeeklyOptions $weeklyGFS -MonthlyOptions $monthlyGFS -YearlyOptions $yearlyGFS

# Apply the GFS policy to the backup job
Set-VBRGFSRetentionPolicy -RetentionPolicy $gfsOptions -RestorePoints 30
New-VBRComputerGFSOptions : A parameter cannot be found that matches parameter name 'WeeklyOptions'

Set-VBRGFSRetentionPolicy : Cannot bind parameter 'RetentionPolicy'. Cannot convert the "Veeam.Backup.PowerShell.Infos.VBRComputerGFSOptions" value of type Veeam.Backup.PowerShell.Infos.VBRComputerGFSOptions" to type "Veeam.Backup.PowerShell.Infos.VBRGFSRetentionPolicy".

Has anyone gotten this to work through PowerShell?
david.domask
Veeam Software
Posts: 2810
Liked: 641 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Creating backup jobs with PowerShell

Post by david.domask »

Hi Miha, welcome to the forums.

New-VBRGFSRetentionPolicy is part of the cmdlet set for Backup Copy Jobs from EC2 backups, so it's not applicable here.

For setting GFS, use Set-VBRJobOptions and to make a new set of job options, use New-VBRJobOptions. To edit an existing job, get the job options with Get-VBRJobOptions.

You will edit several properties of the VBRJoboptions object:

GFSPolicy
BackupTargetOptions #Edit schedule and also enable Synthetic Fulls
BackupStorageOptions.EnableFullBackup #enables/disables periodic Active Full backups

GFS Policy will have all the settings you see in the UI, so just set it as desired. BackupTargetOptions defines how and when a full backup should be made by the job

A few examples:

Code: Select all

$job = Get-VBRJob -name "dd-vcc"
$jOpts = Get-VBRJobOptions -Job $job
$jOpts.GfsPolicy.IsEnabled = $true #Enable GFS
$jOpts.GfsPolicy.Weekly.KeepBackupsForNumberOfWeeks = 10 #Set Weekly Retention
$jOpts.BackupTargetOptions.FullBackupDays = "Thursday" #Set Full Backup day
$jOpts.BackupTargetOptions.FullBackupDays += "Saturday" #Adding multiple days for Full Backups
$jOpts.BackupTargetOptions.TransformToSyntethicDays += "Thursday" #Add Thursday as a Synthetic Full Day
Set-VBRJobOptions -Job $job -Options $jOpts #set the schedule
For setting the on-host proxy for HyperV jobs, you would use:

$jOpts.HvSourceOptions.OffHostBackup

This toggles the off-host/on-host proxy settings, though as we no longer recommend Off-Host proxies due to complexity and stability issues, I would just set it as $False always.
David Domask | Product Management: Principal Analyst
Miha Pecnik
Novice
Posts: 5
Liked: 1 time
Joined: Feb 16, 2025 12:16 pm
Full Name: Miha Pecnik
Contact:

Re: Creating backup jobs with PowerShell

Post by Miha Pecnik »

Thank you works great!

The only issue (that is before I start with the Guest Processing part) is how do I disable the checkbox next to Create synthetic full backups periodically on?
david.domask
Veeam Software
Posts: 2810
Liked: 641 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Creating backup jobs with PowerShell

Post by david.domask »

Hi Miha, glad to hear it worked.

For the SyntheticFull policy, check the JobOptions:

$jOpts.BackupTargetOptions.TransformToSyntheticFull #boolean, set to $true or $false
David Domask | Product Management: Principal Analyst
Miha Pecnik
Novice
Posts: 5
Liked: 1 time
Joined: Feb 16, 2025 12:16 pm
Full Name: Miha Pecnik
Contact:

Re: Creating backup jobs with PowerShell

Post by Miha Pecnik »

I tried that but get:

Code: Select all

$jobOptions.BackupTargetOptions.PerformTransformToSyntethic = $false
The property 'PerformTransformToSyntethic' cannot be found on this object. Verify that the property exists and can be set.
david.domask
Veeam Software
Posts: 2810
Liked: 641 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Creating backup jobs with PowerShell

Post by david.domask »

Ah, the property is called TransformToSyntheticFull, not PerformTransformToSynthetic.
David Domask | Product Management: Principal Analyst
Miha Pecnik
Novice
Posts: 5
Liked: 1 time
Joined: Feb 16, 2025 12:16 pm
Full Name: Miha Pecnik
Contact:

Re: Creating backup jobs with PowerShell

Post by Miha Pecnik » 1 person likes this post

Thank you, works great!

I'm still getting around to automating Guest Processing, I'll probably need some assistance when it comes to that as well.
Miha Pecnik
Novice
Posts: 5
Liked: 1 time
Joined: Feb 16, 2025 12:16 pm
Full Name: Miha Pecnik
Contact:

Re: Creating backup jobs with PowerShell

Post by Miha Pecnik »

OK, I'm back with some issues trying to configure Guest Processing. I managed to enable it using:

Code: Select all

Enable-VBRJobVSSIntegration -Job $job
But now I need to:
1. Customise application hadling options, so that I disable application processing for most VMs, but not for all (would need to specify which ones).
2. Specify a Guest interaction proxy (read about that here: powershell-f26/set-guest-interaction-pr ... 35234.html).
3. Set Guest OS credentials
4. Customise guest OS credentials for individual machines and operating systems.
david.domask
Veeam Software
Posts: 2810
Liked: 641 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Creating backup jobs with PowerShell

Post by david.domask »

Hi miha,

For customizing Application Aware Processing, use Set-VBRjobObjectVSSOptions cmdlet. This one will need some sort of pipeline built that can decide based on the object its processing whether or not it needs AAIP enabled.

I recommend make a test job to play with and try following the examples on the page.

As for Guest Interaction Proxy, yes that should work still.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest