PowerShell script exchange
Post Reply
mjr.epicfail
Veeam Legend
Posts: 397
Liked: 116 times
Joined: Apr 22, 2022 12:14 pm
Full Name: Danny de Heer
Contact:

FR: add option to set deleted VM retention in backupcopyjob

Post by mjr.epicfail »

Hi all,

I'm trying to set the retention for deleted items via powershell in a Backup copy job. https://helpcenter.veeam.com/docs/backu ... ml?ver=120
However I cannot find any reference to set this option.
The alternative was Set-VBRJobOptions (https://helpcenter.veeam.com/docs/backu ... ml?ver=120) however this has been deprecated for backupcopyjobs.

Did I miss the powershell command or doesn't it exist (yet)?
VMCE / Veeam Legend 2*
david.domask
Veeam Software
Posts: 2163
Liked: 519 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: FR: add option to set deleted VM retention in backupcopyjob

Post by david.domask » 1 person likes this post

Hi Danny,

Doesn't seem like you're missing anything, I think the new cmdlet just needs to be updated. Normally you'd get this with Set-VBRBackupCopyJob, but it does not appear to be present yet. I'll check on why that is, but will need a bit of time.

As a unsupported method for workaround, you can use the following code:

Code: Select all

$job = Get-VBRBackupCopyJob -Name 'dd-ps-gfs-test'
$bcj = [Veeam.Backup.Core.CBackupJob]::Find($job.id)
$bcj.Options.GenerationPolicy


EnableDeletedVmDataRetention            : True
DeletedVmsDataRetentionPeriodDays       : 30
...[truncated]

$bcj.Options.GenerationPolicy.EnableDeletedVmDataRetention = $true
$bcj.Update()
You can see on the 3rd line that the Options.GenerationPolicy property has two values to control Deleted Item Retention. Set those as desired, then on the $bcj object, run the Update() method.

This should be fine, but limit the unsupported .NET reflection just to this and use official methods whenever possible.
David Domask | Product Management: Principal Analyst
mjr.epicfail
Veeam Legend
Posts: 397
Liked: 116 times
Joined: Apr 22, 2022 12:14 pm
Full Name: Danny de Heer
Contact:

Re: FR: add option to set deleted VM retention in backupcopyjob

Post by mjr.epicfail »

Hi David,

Yes, I also couldnt find it in Set-VBRBackupCopyJob, also compacting full + schedule isnt present in that cmdlet.
I could add that via "Set-VBRJobAdvancedOptions" (this also works on a backupcopyjob apparently)

Code: Select all

# enable compact full + schedule
$compactschedule = New-VBRMonthlyOptions -dayofweek Sunday -Period 16:00 -DayNumberInMonth Second 
Set-VBRJobAdvancedOptions -job (get-vbrjob -Name "test") -EnableCompactFull -CompactFullScheduleType Monthly -CompactFullMonthlyOptions $compactschedule
I figured it could be done via .NET reflection, however I wanted it done the right way ;)
I'm currently looking into cloning a existing backupcopy job (template) and editing it that way.
That should be completely supported...

Anywho, thank you for responding and supplying a workaround, I hope this missing feature will be added soon
VMCE / Veeam Legend 2*
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests