Retention Policy issues...

PowerShell script exchange

Retention Policy issues...

Veeam Logoby j.h.needed » Fri 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
j.h.needed
Novice
 
Posts: 3
Liked: never
Joined: Fri Feb 10, 2017 10:37 am
Full Name: jason

Re: Retention Policy issues...

Veeam Logoby Andreas Neufert » Sun Feb 12, 2017 7:48 pm

Can you please post the line that uses the $Retention (Start-VBRZip). Thank you.
Andreas Neufert
Veeam Software
 
Posts: 2198
Liked: 357 times
Joined: Wed May 04, 2011 8:36 am
Location: Germany
Full Name: @AndyandtheVMs Veeam PM

Re: Retention Policy issues...

Veeam Logoby j.h.needed » Mon 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
j.h.needed
Novice
 
Posts: 3
Liked: never
Joined: Fri Feb 10, 2017 10:37 am
Full Name: jason

Re: Retention Policy issues...

Veeam Logoby Andreas Neufert » Mon 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.
Andreas Neufert
Veeam Software
 
Posts: 2198
Liked: 357 times
Joined: Wed May 04, 2011 8:36 am
Location: Germany
Full Name: @AndyandtheVMs Veeam PM

Re: Retention Policy issues...

Veeam Logoby v.Eremin » Tue 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.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Retention Policy issues...

Veeam Logoby j.h.needed » Fri Feb 17, 2017 9:45 am

thanks for that link - will give this a try just now
j.h.needed
Novice
 
Posts: 3
Liked: never
Joined: Fri Feb 10, 2017 10:37 am
Full Name: jason

Re: Retention Policy issues...

Veeam Logoby v.Eremin » Sat 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.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Retention Policy issues...

Veeam Logoby Castillo » Wed 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?
Castillo
Lurker
 
Posts: 1
Liked: never
Joined: Wed May 31, 2017 2:47 pm
Full Name: Steve Castell

Re: Retention Policy issues...

Veeam Logoby Andreas Neufert » Thu Jun 01, 2017 7:12 am

I know dump question.... Can you manually create and delete files there?
Andreas Neufert
Veeam Software
 
Posts: 2198
Liked: 357 times
Joined: Wed May 04, 2011 8:36 am
Location: Germany
Full Name: @AndyandtheVMs Veeam PM

Re: Retention Policy issues...

Veeam Logoby v.Eremin » Thu Jun 01, 2017 12:46 pm

Most likely, Veeam service account lacks required permissions on a given share.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests