PowerShell script exchange
Post Reply
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

New job options such as Generation Policy options?

Post by Tobias_Elfstrom »

Hi,
Could someone please give some examples on what options we have with the new option subset; GenerationPolicy on the Backup Job options and explain what the suboptions does, thanks :)

This one:

Code: Select all

>$job = Get-VBRJob -Name Test
>$option = $job.GetOptions()
>$option.GenerationPolicy

DeletedVmsDataRetentionPeriodDays       : 30
RecoveryPointObjectiveValue             : 1
RecoveryPointObjectiveUnit              : Day
SyncIntervalStartTime                   : 00:00:00
RetentionPolicyType                     : Simple
SimpleRetentionRestorePoints            : 7
EnableCompactFull                       : False
CompactFullBackupScheduleKind           : Monthly
CompactFullBackupDays                   : {Saturday}
CompactFullBackupMonthlyScheduleOptions : Veeam.Backup.Model.CDomFullBackupMonthlyScheduleOptions
EnableRechek                            : True
RecheckScheduleKind                     : Monthly
RecheckDays                             : {Saturday}
RecheckBackupMonthlyScheduleOptions     : Veeam.Backup.Model.CDomFullBackupMonthlyScheduleOptions
GFSRecentPoints                         : 7
GFSWeeklyBackups                        : 4
GFSMonthlyBackups                       : 0
GFSQuarterlyBackups                     : 0
GFSYearlyBackups                        : 0
WeeklyBackupDayOfWeek                   : Sunday
WeeklyBackupTime                        : 22:00:00
MonthlyBackup                           : Veeam.Backup.Model.CDomMonthlyBackupCreationTime
QuarterlyBackup                         : Veeam.Backup.Model.CDomQuarterlyBackupCreationTime
YearlyBackup                            : Veeam.Backup.Model.CDomYearlyBackupCreationTime

Also there are new options elsewhere such as

Code: Select all

$option.JobOptions.UseWan
that I assume is the use of the new WAN accel feature?

Maybe some documentation of all the new options is to be found somewhere?

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

Re: New job options such as Generation Policy options?

Post by veremin » 1 person likes this post

Hope the following pictures help you to understand PS GFS commandlets better: 1, 2
that I assume is the use of the new WAN accel feature?
Yep, you’re right in your assumption.

Thanks.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: New job options such as Generation Policy options?

Post by Tobias_Elfstrom » 1 person likes this post

My corporate proxy blocked access to that link (at least it look like the same URL on both 1 and 2 for me) so I put the one I could get on here:
Image

So if you use RententionPolicy = GFS it will ignore the "Restore points to keep" and only go with the settings you specify below "Keep full backups for archival purposes"
I.e
if you go with

Code: Select all

RetentionPolicyType  = Simple
you need to set

Code: Select all

SimpleRetentionRestorePoints 
and if you choose GFS you need to set:

Code: Select all

GFSWeeklyBackups
GFSMonthlyBackups
GFSQuarterlyBackups
GFSYearlyBackups         
Correct?

What about:

Code: Select all

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

Re: New job options such as Generation Policy options?

Post by veremin » 1 person likes this post

Actually, the situation is slightly different.

VB&R GFS rotation scheme keeps backups of different cycle. And backups of different cycle are kept in accordance to different schedules that user can set:

• Regular backup cycle (SimpleRetentionRestorePoints)
• Weekly backup cycle (GFSWeeklyBackups)
• Monthly backup cycle (GFSMonthlyBackups)
• Quarterly backup cycle (GFSQuarterlyBackups)
• Yearly backup cycle (GFSYearlyBackups)

So, even if you decide to stick to GFS rotation scheme, it won’t eliminate the regular backup cycle and you will still have to specify the number of regular backup cycle restore points you’re willing to store.

More information regarding GFS can be found in the corresponding User Guide (p.112).

Thanks.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: New job options such as Generation Policy options?

Post by Tobias_Elfstrom »

Thank you. And I saw you fixed the link to the second images as well:
Image
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New job options such as Generation Policy options?

Post by veremin »

And I saw you fixed the link to the second images as well
Dirty trick, I know. :)
Dario.Palmisano
Enthusiast
Posts: 31
Liked: 2 times
Joined: Nov 11, 2013 7:22 am
Full Name: Dario Palmisano
Contact:

How to change copy job "Restore points to keep"

Post by Dario.Palmisano »

Hello everybody,

I would like to modify with PowerShell the backup copy job parameter "Restore points to keep".

I tried with:

Code: Select all

$CopyJob = Get-VBRJob -Name "base_bk_cp_nas1"

$Options = $CopyJob.GetOptions()

$Options.BackupStorageOptions.RetainDays = 12

$CopyJob.SetOptions($Options)
But accessing the the job using the interface I always get the previous value.

Is the variable corresponding to the parameter I want to change?
What I am making wrong?

Thanks in advance

Best regards

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

Re: New job options such as Generation Policy options?

Post by veremin »

In order to change the number of restore points backup copy job keeps, you should use the following script:

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -name "base_bk_cp_nas1"
$Options = $Job.GetOptions()
$Options.GenerationPolicy.SimpleRetentionRestorePoints = 12
$Job.SetOptions($Options)
More information regarding backup copy job retention settings available via PS can be found in the post provided above.

Thanks.
kbassham
Influencer
Posts: 11
Liked: never
Joined: Jun 14, 2011 6:38 pm
Contact:

Re: New job options such as Generation Policy options?

Post by kbassham »

same problem here... made the change in PS but it doesn't show the change when using the GUI
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New job options such as Generation Policy options?

Post by veremin »

What change you're referring to? Can you post here both what you're trying to achieve and the example of the script you're using? Thanks.
jake1110
Enthusiast
Posts: 40
Liked: 2 times
Joined: Sep 20, 2012 6:19 pm
Full Name: Jake Ernst
Location: Des Moines, IA
Contact:

Re: New job options such as Generation Policy options?

Post by jake1110 »

I think I know what he's referring to. For example, when I set a daily backup time using Powershell it updates the time correctly "behind the scenes" in the database but if I look at the list of jobs in the B&R GUI, they're all still defaulted to 10:00PM under "Next Run." I have 276 jobs staggered out overnight, so it's a bit frustrating to see all 10:00PM on the GUI overview. If I go to edit the actual job, it will report the correct run time.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New job options such as Generation Policy options?

Post by veremin »

Hi, Jake, I'm currently out of the office, but I will take a look at this issue tomorrow morning and see whether this problem can be somehow bypassed. Thanks.
jake1110
Enthusiast
Posts: 40
Liked: 2 times
Joined: Sep 20, 2012 6:19 pm
Full Name: Jake Ernst
Location: Des Moines, IA
Contact:

Re: New job options such as Generation Policy options?

Post by jake1110 »

No problem at all! It's just a minor quirk I noticed and doesn't affect me a whole lot, just others who are looking at the console.

For performance reasons, I'm breaking the jobs up into three servers. I wasn't able to scale up as high as I thought, but that's a whole other topic!
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New job options such as Generation Policy options?

Post by veremin »

Hi, Jake, are talking about schedule of ordinary backup job, not backup copy job, as the latter doesn't have any time-specific schedule being of continuous type?

In case of backup job, you can use the following script that should meet your expectations:

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup Job"
$Options = $Job.Options 
$ScheduleOptions = $Job.GetScheduleOptions()
$ScheduleOptions.OptionsDaily.Enabled = $true
$ScheduleOptions.OptionsMonthly.Enabled = $false
$ScheduleOptions.OptionsPeriodically.Enabled = $false
$ScheduleOptions.OptionsContinuous.Enabled = $false
$ScheduleOptions.NextRun = "22:00" #Write here whatever time you want to
Set-VBRJobScheduleOptions -Job $Job -Options $ScheduleOptions
$Options.Options.RootNode.RunManually = "False"
$Job.SetOptions($Options)
I've just checked it, and everything seems to be working fine.

Thanks.
jake1110
Enthusiast
Posts: 40
Liked: 2 times
Joined: Sep 20, 2012 6:19 pm
Full Name: Jake Ernst
Location: Des Moines, IA
Contact:

Re: New job options such as Generation Policy options?

Post by jake1110 »

Yes, this is now working for me using your snippet

What I was doing was updating my schedules using:

Code: Select all

Set-VBRJobSchedule -job "Job Name" -At "23:30" -DailyKind Everday #or anytime
This would update the time of the job but not when I looked at the overview of jobs in the GUI.

Now using:

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Job Name"
$Options = $Job.Options 
$ScheduleOption = $Job.GetScheduleOptions()
$ScheduleOption.NextRun = "23:30"
$Job.SetOptions($Options)
Thanks for the help
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New job options such as Generation Policy options?

Post by veremin »

Glad to hear that everything is working now. Also, please be aware that the script you've posted will work if the "Run the job automatically" option is ticked. Otherwise, you will have to add the following lines in order to enable it:

Code: Select all

$Options.Options.RootNode.RunManually = "False"
$Job.SetOptions($Options)
Thanks.
Lewpy
Enthusiast
Posts: 66
Liked: 15 times
Joined: Nov 27, 2012 1:00 pm
Full Name: Lewis Berrie
Location: Southern England
Contact:

Re: New job options such as Generation Policy options?

Post by Lewpy »

Apologies for digging up a 3 year old post, but this was top search result by a well known search engine that rhymes with "moogle" using the terms "veeam powershell simpleretentionrestorepoints" (as I searched :wink: )

I wanted to update the information in here, as there are now some inaccuracies (based on my recent experiences with v9.5)

Background
I have a customer for whom I have recently performed a massive VMware upgrade, which involved new vCenter and lots of consolidation.
As such, the Veeam backups were pretty much recreated from scratch, with no attempt at mapping VMs back to their old backup files (as jobs consolidated down too).
They had Veeam Backup Copy Jobs with a GFS retention specified running off the original backup jobs, going to a Windows 2012 R2 repository that is running Windows Deduplication. These jobs had 28 normal retentions, plus monthly, quarterly and yearly, and are need to be kept until the new backups reach that age of retentions.
Now, I had configured Windows Deduplication to ignore .VIB files, for performance-reasons when backup merges occurred (because the .VIB file will be untouched for 28 days by the time it merges, and will have been deduplicated), and these .VIB files are consuming a fair amount of space (uncompressed and non-deduped).
The Backup Copy Jobs aren't actively processing any backup data now, so I wanted to wind down the number of retentions that the old Backup Copy Jobs maintained at a rate of 1 per day, as the new Backup Copy Jobs ramped up the recovery points 1 per day (therefore maintaining the same number/days of retention per VM, that exists in both old and new backup jobs .... are you still following me? :D )
Doing this manually is tedious, so I looked to write a script to decrement the "restore points to keep" value in the Backup Copy Jobs once per day, so as to trigger a backup merger once a day and remove a .VIB file.

Implementation
I started by researching the Veeam PowerShell commands and attributes/values I would need to alter, and hence I arrived at this thread :)
Now, initially I tried altering

Code: Select all

$JobOptions.GenerationPolicy.SimpleRetentionRestorePoints
but using PowerShell doesn't cause the backup copy job to restart (unlike the GUI), so it doesn't have an immediate effect.
So I tried letting the job reach the end of its cycle (every day at midnight) to see if it re-read its settings, but it didn't and the change had no effect.
I then determined that I would have to "sandwich" my alteration of the job options in-between Disabling the Backup Copy Job and then enabling it again afterwards.
However, I found out that the code executed too fast most of the time! This meant that the Backup Copy Job didn't disable and stop before the Enable command re-enabled it, so the change didn't take effect [still!]. (I would say about 1 in 10 times the Backup Copy Job did actual stop and restart, but 9 in 10 times it managed to avoid stopping altogether).
I then added code to wait for the Backup Copy Job to actual stop after issuing the Disable command, and then the Backup Copy Job did actually stop, and restart (as expected).
BUT ... it still didn't work, and no backup mergers took place :( The value in the GUI had decremented though.
So this is when I looked harder and found that although the SimpleRetentionRestorePoints had decremented, the value of ActualRetentionRestorePoints was still the original value and so was GFSRecentPoints.
I changed the code to decrement both SimpleRetentionRestorePoints AND GFSRecentPoints (to the same value), and voila :D ActualRetentionRestorePoints now showed the correct decremented value and a backup merger took place (removing the oldest restore point, as expected).

So, if GFS retention is specified, it is not the value of SimpleRetentionRestorePoints that matters, but the value of GFSRecentPoints. I haven't tried decrementing GFSRecentPoints without decrementing SimpleRetentionRestorePoints, but I now have the strong feeling that the two values should actually be kept the same. The GUI seems to do this.

My code (with no error checking and basic functionality) is

Code: Select all

function ReduceBackupCopyJobRetention
{
  param
  (
    $JobName
  )
  
  $CopyJob = Get-VBRJob -Name $JobName

  If ($CopyJob.IsIdle)
  {
    Disable-VBRJob -Job $CopyJob
    While (!$CopyJob.IsStopped()) {}
  }
  
  $JobOptions = Get-VBRJobOptions -Job $CopyJob
  $RestorePoints = $JobOptions.GenerationPolicy.GFSRecentPoints
  $RestorePoints -= 1
  If ($RestorePoints -le 1)
  {
    RestorePoints = 2
  }
  $JobOptions.GenerationPolicy.SimpleRetentionRestorePoints = $RestorePoints
  $JobOptions.GenerationPolicy.GFSRecentPoints = $RestorePoints
  Set-VBRJobOptions -Job $CopyJob -Options $JobOptions
  
  Enable-VBRJob -Job $CopyJob
}
The GUI doesn't let the number of "restore points to keep" go below 2, so I check and don't let it go smaller than that.
Now the old Backup Copy Jobs should slow reduce their restore points (and .VIB files, and their consumed disk space), and eventually I will delete them and let the .VBK points get full deduplicated and retained until no longer required :)
I do an "IsIdle" check in case the Backup Copy Job is in the middle of doing a GFS restore point creation, as this can take a very long time (over a day sometimes, depending on how many jobs are trying to copy entire restore points to new VBK files .... yes Windows 2016 and new ReFS looks very interesting ;) )
Lewpy
Enthusiast
Posts: 66
Liked: 15 times
Joined: Nov 27, 2012 1:00 pm
Full Name: Lewis Berrie
Location: Southern England
Contact:

Re: New job options such as Generation Policy options?

Post by Lewpy » 1 person likes this post

Ahem :) Let me fix the [basic] mistake in the code I shared :oops: [not enough dollars!]
And a small tweak so as to only re-enable the job if it was stopped.

Code: Select all

function ReduceBackupCopyJobRetention
{
  param
  (
    $JobName
  )
  
  $CopyJob = Get-VBRJob -Name $JobName

  If ($CopyJob.IsIdle)
  {
    Disable-VBRJob -Job $CopyJob
    While (!$CopyJob.IsStopped()) {}
  }
  
  $JobOptions = Get-VBRJobOptions -Job $CopyJob
  $RestorePoints = $JobOptions.GenerationPolicy.GFSRecentPoints
  $RestorePoints -= 1
  If ($RestorePoints -le 1)
  {
    $RestorePoints = 2
  }
  $JobOptions.GenerationPolicy.SimpleRetentionRestorePoints = $RestorePoints
  $JobOptions.GenerationPolicy.GFSRecentPoints = $RestorePoints
  Set-VBRJobOptions -Job $CopyJob -Options $JobOptions
  
  If ($CopyJob.IsStopped())
  {
    Enable-VBRJob -Job $CopyJob
  }
}
With my code 'anomaly', I managed to programmatically set the number of restore points lower than 2 (the limit the GUI sets).
When it reached 0, I couldn't actually edit the job in the GUI: it raised an error and refused to open the job.
I had to fix it via PowerShell, then I could edit the job again :wink:
Although it did wind the current backup chain down to zero restore points, which was interesting :)
siranee.ja
Influencer
Posts: 24
Liked: 5 times
Joined: Mar 11, 2019 1:13 am
Contact:

Re: New job options such as Generation Policy options?

Post by siranee.ja »

Hi Lewpi,

Thank you very much for the code to set the number of restore points. I used almost the same code as your posted. I tested on Veeam 10 community Edition. I found that If I only disable and enable the backup copy job, it work perfectly.
If I disable the job and then set the $JobOptions.GenerationPolicy.SimpleRetentionRestorePoints =8 and after that enable the job. The job still disabled. I have to enable the job via GUI.

Could anyone help me with this problem?
Best Regards,
Siranee Jaraswachirakul.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: New job options such as Generation Policy options?

Post by veremin »

Can you post your script here, so, we can confirm it? Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests