PowerShell script exchange
j.h.needed
Novice
Posts: 3
Liked: never
Joined: Feb 10, 2017 10:37 am
Full Name: jason
Contact:

Retention Policy issues...

Post by j.h.needed » Feb 10, 2017 11:00 am

Hi there,

We've recently (at last) upgraded our Veeam Backup and Restore (free version) from 9.0 to 9.5.

Since the upgrade our scheduled tasks (utilising the powershell script for scheduled backups) no longer pay attention to the retention policy - no backups are removed now.
The retention policy has been set to a combination of 'Tonight' or 'TomorrowNight' in different locations - we have the solution installed in 4 different locations. Regardless of the location - all backup instances have exhibited the same behaviour of aged backups no longer being removed.

Note: backups all run successfully with no other issues seen.

Is there something obvious that I've overlooked or need to amend as part of the update to 9.5?

Code: Select all

----------------------------------
##################################################################
#                   User Defined Variables
##################################################################

# Names of VMs to backup separated by comma (Mandatory). For instance, $VMNames = “VM1”,”VM2”
$VMNames = "server1","server2","server3"
# Name of vCenter or standalone host VMs to backup reside on (Mandatory)
$HostName = "serverHVhost"
 
# Directory that VM backups should go to (Mandatory; for instance, C:\Backup)
$Directory = "\\serverbackup\folder"

# Desired compression level (Optional; Possible values: 0 - None, 4 - Dedupe-friendly, 5 - Optimal, 6 - High, 9 - Extreme)
$CompressionLevel = "9"

# Quiesce VM when taking snapshot (Optional; VMware Tools or Hyper-V Integration Components are required for this in the guest OS; Possible values: $True/$False)
$EnableQuiescence = $False

# Protect resulting backup with encryption key (Optional; $True/$False)
$EnableEncryption = $False

# Encryption Key (Optional; path to a secure string)
$EncryptionKey = ""

# Retention settings (Optional; by default, VeeamZIP files are not removed and kept in the specified location for an indefinite period of time.
# Possible values: Never, Tonight, TomorrowNight, In3days, In1Week, In2Weeks, In1Month)
$Retention = "Tonight"
---------------------------------------

Thanks in advance

Jason

Andreas Neufert
Veeam Software
Posts: 3298
Liked: 576 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert Director of Product Management Global Alliances
Location: Germany
Contact:

Re: Retention Policy issues...

Post by Andreas Neufert » Feb 12, 2017 7:48 pm

Can you please post the line that uses the $Retention (Start-VBRZip). Thank you.

j.h.needed
Novice
Posts: 3
Liked: never
Joined: Feb 10, 2017 10:37 am
Full Name: jason
Contact:

Re: Retention Policy issues...

Post by j.h.needed » Feb 13, 2017 9:02 am

Hi, we have:-

Code: Select all

-------------------------------
$Server = Get-VBRServer -name $HostName
$MesssagyBody = @()

foreach ($VMName in $VMNames)
{
  $VM = Find-VBRHvEntity -Name $VMName -Server $Server
  
  If ($EnableEncryption)
  {
    $EncryptionKey = Add-VBREncryptionKey -Password (cat $EncryptionKey | ConvertTo-SecureString)
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention -EncryptionKey $EncryptionKey
  }
  
  Else 
  {
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention
  }
  
  If ($EnableNotification) 
  {
    $TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog().updatedrecords
    $FailedSessions =  $TaskSessions | where {$_.status -eq "EWarning" -or $_.Status -eq "EFailed"}
  
  if ($FailedSessions -ne $Null)
  {
    $MesssagyBody = $MesssagyBody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result,@{n="Details";e={$FailedSessions.Title}})
  }
   
  Else
  {
    $MesssagyBody = $MesssagyBody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result)
  }
  
  }   
}
------------------------------
Thank you

Andreas Neufert
Veeam Software
Posts: 3298
Liked: 576 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert Director of Product Management Global Alliances
Location: Germany
Contact:

Re: Retention Policy issues...

Post by Andreas Neufert » Feb 13, 2017 10:11 am

Looks good.
We can try to install update 1 https://www.veeam.com/kb2222
and if this will not help we need to open a ticket please.
Please post the ticket number here then.

v.Eremin
Product Manager
Posts: 15946
Liked: 1280 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Retention Policy issues...

Post by v.Eremin » Feb 14, 2017 9:06 am

I've tested it on 9.5 Update 1, the retention policy has worked as expected deleting created backup files the other night. Thanks.

j.h.needed
Novice
Posts: 3
Liked: never
Joined: Feb 10, 2017 10:37 am
Full Name: jason
Contact:

Re: Retention Policy issues...

Post by j.h.needed » Feb 17, 2017 9:45 am

thanks for that link - will give this a try just now

v.Eremin
Product Manager
Posts: 15946
Liked: 1280 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Retention Policy issues...

Post by v.Eremin » Feb 18, 2017 11:21 am

Jason, if the retention doesn't work, can you, please, try to reproduce the behaviour via GUI as well?

We've checked the structure of this cmdlet and connection between cmdlet wrappers and internal db calls seems to be right. So, the experienced problem may lay outside of PowerShell functionality.

Thanks.

Castillo
Lurker
Posts: 1
Liked: never
Joined: May 31, 2017 2:47 pm
Full Name: Steve Castell
Contact:

Re: Retention Policy issues...

Post by Castillo » May 31, 2017 2:54 pm

Hi,
I'm getting the same problem with backups not deleting after the retention period has expired.

This issue does not occur if the backup file is located on a local disk on the Veeam Server, but when the backup is located on a UNC share then it does not delete after the specified retention period.

We're running Veeam Backup and Replication 9.5 Update 2 Free Edition.

Is anyone else having this issue?

Andreas Neufert
Veeam Software
Posts: 3298
Liked: 576 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert Director of Product Management Global Alliances
Location: Germany
Contact:

Re: Retention Policy issues...

Post by Andreas Neufert » Jun 01, 2017 7:12 am

I know dump question.... Can you manually create and delete files there?

v.Eremin
Product Manager
Posts: 15946
Liked: 1280 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Retention Policy issues...

Post by v.Eremin » Jun 01, 2017 12:46 pm

Most likely, Veeam service account lacks required permissions on a given share.

Jawloms
Lurker
Posts: 1
Liked: never
Joined: Oct 17, 2017 10:44 am
Full Name: Stuart Hawkins
Contact:

Re: Retention Policy issues...

Post by Jawloms » Oct 17, 2017 10:47 am

j.h.needed - Did you sort this as I have just upgraded to 9.5 Update 2 and am having the same problem.

Thank you

Stuart

FreekouT
Lurker
Posts: 1
Liked: never
Joined: Jan 19, 2018 8:50 am
Contact:

Re: Retention Policy issues...

Post by FreekouT » Jan 19, 2018 8:54 am

I figured out, that when I delete all VMs backups from target location, the retention policy set in Powershell script starts to work properly.

v.Eremin
Product Manager
Posts: 15946
Liked: 1280 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Retention Policy issues...

Post by v.Eremin » Jan 23, 2018 1:35 pm

By the way, in Update 2 there used to be problems with VeeamZIP retention policy not applying correctly. Those issues are addressed in Update 3; might be worth updating. Thanks.

Leutin
Novice
Posts: 3
Liked: never
Joined: Feb 05, 2018 8:05 am
Contact:

Re: Retention Policy issues...

Post by Leutin » Feb 05, 2018 8:17 am

Hello!
I'm using free version of Veeam B&R 9.5 update 3 (9.5.0.1536), and exrepiencing issues with the retention too.
Every night I run script that backups VMs to the UNC share with the credentials previously added to the VB&R via Console:

Code: Select all

$Credentians = "credentials name as shown in the VB&R Console"
$EncryptionKeyDescription = "encryption key description as shown int the VB&R Console"
$NetCreds = Get-VBRCredentials -Name $Credentials
$ZIPSession = Start-VBRZip -Entity $VM `
                           -Folder "\\nas\backups" `
                           -Compression $CompressionLevel `
                           -DisableQuiesce:$False `
                           -AutoDelete "In1Week" `
                           -NetworkCredentials $NetCreds `
                           -EncryptionKey (Get-VBREncryptionKey -Description $EncryptionKeyDescription)
UNC share is located on the Synology NAS. Of cource, I created separete account on NAS and gave it needed permissions, then added credential to the VB&R.
Encrtyption key added via VB&R console, too.
Backups saved as well, but it does not deleted after time interval specified in the command-line.

How could I fix this issue?

v.Eremin
Product Manager
Posts: 15946
Liked: 1280 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Retention Policy issues...

Post by v.Eremin » Feb 05, 2018 3:17 pm

Hmm, can you reproduce this via GUI? Anyway, it might be worth opening a support ticket and letting them check debug logs. Thanks.

Post Reply

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests