PowerShell script exchange
Post Reply
ToniVR
Influencer
Posts: 20
Liked: 4 times
Joined: Aug 17, 2012 3:50 pm
Full Name: Toni Van Remortel
Contact:

Configure GFS for all backup jobs

Post by ToniVR »

Hi,

I'm trying to enable GFS for all our backup jobs, but even with the help of Veeam support I can't get it working.
This is what the suggestion is from support:

Code: Select all

$jobs = Get-VBRJob | ?{$_.JobType -eq "Backup"}
Foreach ($job in $jobs) {
$job.GetOptions().GFSpolicy.isenabled = $true
$job.Update()
$policy = Get-VBRRetentionPolicy -Job $job
Set-VBRGFSRetentionPolicy -RetentionPolicy $policy -RestorePoints 8 -GFSWeeklyBackups 10 -GFSMonthlyBackups 6 -GFSYearlyBackups 5
}
The Set-VBRGFSRetentionPolicy always complains:
Cannot convert the "Veeam.Backup.PowerShell.Infos.
VBRSimpleRetentionPolicy" value of type "Veeam.Backup.PowerShell.Infos.VBRSimpleRetentionPolicy" to type "Veeam.Backup.
PowerShell.Infos.VBRGFSRetentionPolicy".


I have been digging around in the help pages, but I can't get it working.

Any advise on how to configure GFS for all jobs with PowerShell?
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Configure GFS for all backup jobs

Post by oleg.feoktistov » 1 person likes this post

Hi Toni,

The script you got doesn't work as Set-VBRGFSRetentionPolicy and Get-VBRRetentionPolicy cmdlets are applicable only for backup copy jobs with backups on external repositories (azure or aws) and agent backup copy jobs. You can find all the info on these types and acceptable parameters here.
For regular backup jobs it's a whole other story. As far as I understood, you need to setup the same retention policies for all regular backup jobs. Here is the script:

Code: Select all

$jobs = Get-VBRJob | ?{$_.JobType -eq "Backup"}
foreach ($job in $jobs) {
   $options = Get-VBRJobOptions -Job $job
   $options.BackupStorageOptions.RetainCycles = 8
   $options.GfsPolicy.IsEnabled = $true
   $options.GfsPolicy.Weekly.IsEnabled = $true
   $options.GfsPolicy.Weekly.KeepBackupsForNumberOfWeeks = 10
   $options.GfsPolicy.Monthly.IsEnabled = $true
   $options.GfsPolicy.Monthly.KeepBackupsForNumberOfMonths = 6
   $options.GfsPolicy.Yearly.IsEnabled = $true
   $options.GfsPolicy.Yearly.KeepBackupsForNumberOfYears = 5 
   Set-VBRJobOptions -Job $job -Options $options

}
JobOptions cmldets operate over properties, which are not described in our documentation, but you still can discover property trees for objects with preinstalled Get-Member or Show-Object from PowershellCookBook module in such way:

Code: Select all

$options = New-VBRJobOptions
$options | Get-Member
$options | Show-Object
Do let us know if you have any further questions.

Thanks,
Oleg
ToniVR
Influencer
Posts: 20
Liked: 4 times
Joined: Aug 17, 2012 3:50 pm
Full Name: Toni Van Remortel
Contact:

Re: Configure GFS for all backup jobs

Post by ToniVR »

Hi Oleg,

Thanks for the explanation. It all makes more sense now :-)

Your script works like expected, so thanks for that. Made my life easier :-)

Regards,
Toni
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Configure GFS for all backup jobs

Post by oleg.feoktistov » 1 person likes this post

Thanks Toni. I'm really glad to know I could help.

Just a side note - if you want to change only precise settings for each job, make sure options amendments stay inside foreach loop.
Otherwise, you are running a risk of assigning all options of one job to all jobs.
Cheers,
Oleg
Mildur
Product Manager
Posts: 8673
Liked: 2275 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Configure GFS for all backup jobs

Post by Mildur »

Hi Oleg

Thanks for that script, it will help me in my new project :)
Product Management Analyst @ Veeam Software
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests