PowerShell script exchange
Post Reply
vmm
Service Provider
Posts: 15
Liked: never
Joined: Nov 23, 2015 10:09 am
Full Name: Marat Akhmetianov
Contact:

Cannot enable VM retention policy

Post by vmm »

Code: Select all

$vps = Find-VBRViEntity -Name "vps-8"
$repository = Get-VBRBackupRepository -Name "Backup Repository 1"
Add-VBRViBackupJob -Name "DM_TEST" -Entity $vps -BackupRepository $repository
Get-VBRJob -Name "DM_TEST" | Set-VBRJobAdvancedBackupOptions -Algorithm ReverseIncremental 
Get-VBRJob -Name "DM_TEST" | Set-VBRJobAdvancedOptions -RetainDays 14
Get-VBRJob -Name "DM_TEST" | Set-VBRJobAdvancedViOptions -VMToolsQuiesce $True 
$Job = Get-VBRJob -Name "DM_TEST"
$Options = $Job.GetOptions()
$Options.SanIntegrationOptions.FailoverFromSan = $True
$Options.BackupStorageOptions.StgBlockSize = "KbBlockSize512"
$Options.BackupStorageOptions.RetainCycles = 1
$Job.SetOptions($Options) 
After issuing this script I can change VM retention policy (number of days) but can not enable it
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Cannot enable VM retention policy

Post by veremin »

What do you mean by enable? The retention policy is enabled by default, and cannot be disabled. Or you're talking about deleted VM retention?
vmm
Service Provider
Posts: 15
Liked: never
Joined: Nov 23, 2015 10:09 am
Full Name: Marat Akhmetianov
Contact:

Re: Cannot enable VM retention policy

Post by vmm »

Yes for deleted VM retention.
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Cannot enable VM retention policy

Post by veremin »

Then, try the following script:

Code: Select all

$Job = Get-VBRJob -Name "Job Name"
$Options = $Job.GetOptions()
$Job.BackupStorageOptions.EnableDeletedVmDataRetention = $true
$Options.BackupStorageOptions.RetainDays = "Desired value" 
$Job.SetOptions($Options)
Thanks.
vmm
Service Provider
Posts: 15
Liked: never
Joined: Nov 23, 2015 10:09 am
Full Name: Marat Akhmetianov
Contact:

Re: Cannot enable VM retention policy

Post by vmm »

Great. Thanks. Everything worked
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Cannot enable VM retention policy

Post by veremin »

You're welcome. Should other help be needed, don't hesitate to let us know. Thanks.
evilaedmin
Expert
Posts: 176
Liked: 30 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

[MERGED] "Remove deleted items data after <N> days "

Post by evilaedmin »

Greetings,

Which powershell value is equivalent of "Remove deleted items data after <N> days " ?

https://helpcenter.veeam.com/docs/backu ... tml?ver=95
https://helpcenter.veeam.com/docs/backu ... tml?ver=95

Thank you,
evilaedmin
Expert
Posts: 176
Liked: 30 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

Re: "Remove deleted items data after <N> days "

Post by evilaedmin »

I think I found it:

Code: Select all

    $JobOptions.BackupStorageOptions.RetainDays
    $JobOptions.BackupStorageOptions.EnableDeletedVmDataRetention
Is there a reference for mapping the graphic interface elements to Powershell? I don't believe these are obvious at all at first glance!
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Cannot enable VM retention policy

Post by veremin » 1 person likes this post

Yep, you've found the proper way to modify those settings. Don't forget to apply new values via .SetOptions method. Thanks!
evilaedmin
Expert
Posts: 176
Liked: 30 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

Re: Cannot enable VM retention policy

Post by evilaedmin »

Don't forget to apply new values via .SetOptions method.
I used the pattern in the example 1:

Code: Select all

    $JobOptions = Get-VBRJobOptions -Job $job
    $JobOptions.BackupStorageOptions.RetainDays = 90
    $JobOptions.BackupStorageOptions.EnableDeletedVmDataRetention = $True
    Set-VBRJobOptions -Job $job -Options $JobOptions
   
Is that what you mean?
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Cannot enable VM retention policy

Post by veremin » 1 person likes this post

Correct, new settings can be applied either via cmdlet Set-VBRJobOptions or job dynamic method .SetOptions() (for instance, $Job.SetOptions($JobOptions)). Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests