PowerShell script exchange
Post Reply
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

Change retaindays on backup copy jobs

Post by vraengmose »

Hi

I been trying to set "Remove deleted data after" in Storage/Maintenance through Powershell ("retainday") in backup jobs and backup copy jobs. And got it to work with

backup jobs:

Code: Select all

Asnp VeeamPSSnapin
$Jobs = Get-VBRJob | where {$_.Jobtype -eq "Backup"}
foreach ($Job in $Jobs)
{
$Options = $Job.GetOptions()
$Options.backupstorageoptions.retaindays = "30"
$Options.BackupStorageOptions.EnableDeletedVmDataRetention = $True
Set-VBRJobOptions -Job $Job -Options $Options
}
But when i try on backup copy jobs it dos not work

Code: Select all

Asnp VeeamPSSnapin
$Jobs = Get-VBRJob | where {$_.Jobtype -eq "BackupSync"}
foreach ($Job in $Jobs)
{
$Options = $Job.GetOptions()
$Options.backupstorageoptions.retaindays = "60"
$Options.BackupStorageOptions.EnableDeletedVmDataRetention = $True
Set-VBRJobOptions -Job $Job -Options $Options
} 
Any ideas?
veremin
Product Manager
Posts: 20283
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Change retaindays on backup copy jobs

Post by veremin » 1 person likes this post

Check this example:

Code: Select all

Asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup copy Job"
$Options = $Job.GetOptions()
$Options.generationpolicy.EnableDeletedVmDataRetention = $True
$Options.generationpolicy.DeletedVmsDataRetentionPeriodDays = ''Desired number of days"
Set-VBRJobOptions -Job $Job -Options $Options
Thanks!
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

Re: Change retaindays on backup copy jobs

Post by vraengmose »

It did not work on my backup copy jobs as wised.
I discovered that the function is not under storage but under target, in a backup copy job. Target>advanced>Maintenance.

Any other ideas?
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

Re: Change retaindays on backup copy jobs

Post by vraengmose »

NO it did work! i forgot to change the {$_.Jobtype -eq "BackupSync"}

Did all copy jobs with this:

Code: Select all

Asnp VeeamPSSnapin
$Jobs = Get-VBRJob | where {$_.Jobtype -eq "BackupSync"}
foreach ($Job in $Jobs)
{
$Options = $Job.GetOptions()
$Options.generationpolicy.EnableDeletedVmDataRetention = $True
$Options.generationpolicy.DeletedVmsDataRetentionPeriodDays = "22"
Set-VBRJobOptions -Job $Job -Options $Options
}
Thanks for your help v.eremin!
veremin
Product Manager
Posts: 20283
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Change retaindays on backup copy jobs

Post by veremin » 1 person likes this post

You're welcome. Deleted VM retention settings should be modified differently for backup and backup copy jobs - backupstorageoptions and generationpolicy, respectively. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests