PowerShell script exchange
fabio.r
Lurker
Posts: 1
Liked: never
Joined: Feb 13, 2018 9:57 am
Contact:

Re: Retention Policy issues...

Post by fabio.r » Feb 13, 2018 10:01 am

Hello, I have the same situation of Leutin, but without encryption and retention set to In3Days, have you found a solution?

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

Re: Retention Policy issues...

Post by Leutin » Feb 19, 2018 1:28 pm

v.Eremin wrote:Hmm, can you reproduce this via GUI?
Unfortunately, no - I use free version, and I don't know how to use autoretention feature via GUI.
Also, I met solution in the internet to give Veeam machine AD account give permissions to the UNC share used for backups.
I was unable to do it because UNC share located on the Synology NAS, so I created separate AD user, give it permissions to the share and set Veeam Data Mover Service to run with this account.
This does not solved the issue - backups still not removed automatically.
v.Eremin wrote:Anyway, it might be worth opening a support ticket and letting them check debug logs. Thanks.
I am a newbie here, so I don't know how to open a support ticket yet.

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

Re: Retention Policy issues...

Post by v.eremin » Feb 19, 2018 2:26 pm

Unfortunately, no - I use free version, and I don't know how to use autoretention feature via GUI.
You can apply retention policy to VeeamZIP backup even in free edition. (delete this backup automatically setting)
Also, I met solution in the internet to give Veeam machine AD account give permissions to the UNC share used for backups.
Specify required account as credentials in the same UI wizard and see whether the issue is reproduced.

Thanks.

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

Re: Retention Policy issues...

Post by Leutin » Feb 20, 2018 7:32 am

OK. I made two backups of two different VMs with different autodelete settings ("Tonight" and "Tomorrow Night") via GUI, will check if it will be autodeleted.

Manual said:

Code: Select all

Veeam Backup & Replication checks the
retention policy set for the job. If some backup files in the backup chain are outdated,
Veeam Backup & Replication removes them from the backup chain.

VeeamZIP files are automatically deleted after some period of time: on the same night, the next night, in 3 days, in a week and so on.
Which process should remove old backups, and when should it be removed?
Should it be task for same machine with the same destination?
Could I have backups of the same VM in the same destination with different autoretention settings at the same time?
It's not clear in the documentation.

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

Re: Retention Policy issues...

Post by v.eremin » Feb 20, 2018 1:09 pm

Which process should remove old backups, and when should it be removed?
Should be removed tonight and tomorrow night by backup server.
Should it be task for same machine with the same destination?
Unfortunately, I didn't get the question, could you elaborate?
Could I have backups of the same VM in the same destination with different autoretention settings at the same time?
Yes, you can.

Marco.S
Lurker
Posts: 2
Liked: never
Joined: Feb 28, 2018 10:50 am
Full Name: Marco Sai
Contact:

Re: Retention Policy issues...

Post by Marco.S » Feb 28, 2018 12:56 pm

Hi All,
We experience the same problems with the retention rules.
Those customers who use the licensed version of veeam 9.5 have no problems, horewer we have 2 cases where the free edition is used.
In both cases, using veeam 9.5 update 3 (one is an upgrade from 9.0 the other is a fresh install) we are able to create backups on the network share but older backup are not deleted.

I tried using the gui, creating a backup using the retention (with delete tonight option) and they are not autodeleted.
The network share is in both cases a synology nas.
I tried to set permissions to windows acl and also tried to setup the user as administrator but still no effects.

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

Re: Retention Policy issues...

Post by v.eremin » Feb 28, 2018 3:37 pm

I tried using the gui, creating a backup using the retention (with delete tonight option) and they are not autodeleted.
In this case log a ticket with our support team and let them confirm your environment. Thanks.

Marco.S
Lurker
Posts: 2
Liked: never
Joined: Feb 28, 2018 10:50 am
Full Name: Marco Sai
Contact:

Re: Retention Policy issues...

Post by Marco.S » Mar 05, 2018 9:01 pm

Hi all,

I opened a ticket and I had a remote connection with veeam support (BTW IT'S AMAZING!), the problem seems to be that the $netcreds variable only work for opeming the remote share connection.
The veeam backup service instead work using the local machine account so when it tries to delete the files it receives a "permission denied" from the remote NAS.

Support suggested that the local machine account and the remote repository share account must be the same, so I guess both devices must be under active directory and using the same account.

Horewer I can't test this since they are very small business, they don't have an avaible domain controllers.

Edit: solved the problem using synology scheduler to delete files older than I need from the repository folder

This info maybe can solve this problems for other people.

ycl
Lurker
Posts: 1
Liked: never
Joined: Feb 09, 2018 11:42 am
Contact:

Re: Retention Policy issues...

Post by ycl » Mar 07, 2018 11:31 am

Hi all,

Got the same problem. From the log, seems it backup with the netcred provided but not deleting it with the same netcred

Code: Select all

[07.03.2018 00:00:23] <64> Info     [VeeamZIPRetention] Deleting file [\\"NASpath"\test pcD2018-03-06T171849.vbk] on repository [Local filesystem] because it's due is 7/3/2018 0:00:00 
[07.03.2018 00:00:23] <64> Info         [Local] Check existing '\\"NASpath"\test pcD2018-03-06T171849.vbk'
[07.03.2018 00:00:24] <64> Warning  [VeeamZIPRetention] Cannot delete the file [\\"NASpath"\test pcD2018-03-06T171849.vbk] on the repository [Local filesystem] because it does not exist or you have no permissions to access to this location.
We didn't mount the NAS on server, the last ransomware attack encrypted the backup because the pc had access to its backup on NAS

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

Re: Retention Policy issues...

Post by v.eremin » Mar 07, 2018 11:36 am

We're checking this at the moment. Will update the topic, once I have more information. Thanks.

nzorn
Influencer
Posts: 22
Liked: never
Joined: Nov 13, 2014 2:57 pm
Contact:

Re: Retention Policy issues...

Post by nzorn » May 21, 2018 2:15 pm

Any update on this? I believe we are also seeing this with the -NetworkCredentials switch.

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

Re: Retention Policy issues...

Post by v.eremin » May 24, 2018 9:45 pm

QA team believe that retention policy issues have been solved in Update 3.

If you still experience these problems, kindly, open a ticket with our support team, provide required logs and post case number here.

Thanks.

nzorn
Influencer
Posts: 22
Liked: never
Joined: Nov 13, 2014 2:57 pm
Contact:

Re: Retention Policy issues...

Post by nzorn » May 30, 2018 2:38 pm

Thanks, Case # 03031584

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

Re: Retention Policy issues...

Post by v.eremin » Jun 01, 2018 5:03 pm

Based on the provide support ticket, it seems to be permissions issue. Can you tell me whether within a script you've specified share credentials using -NetworkCredentials parameter? Thanks.

nzorn
Influencer
Posts: 22
Liked: never
Joined: Nov 13, 2014 2:57 pm
Contact:

Re: Retention Policy issues...

Post by nzorn » Jun 04, 2018 1:19 pm

My actual script is attached to the case if that helps, but I modified the https://www.veeam.com/blog/veeam-backup ... shell.html script slightly to add in the -NetworkCredentials:

$DirectoryCreds = "VEEAM"

$NetCreds = Get-VBRCredentials -Name "$DirectoryCreds"

$ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention -EncryptionKey $EncryptionKey -NetworkCredentials $netcreds

$ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention -NetworkCredentials $netcreds



Code: Select all



# Author: Vladimir Eremin
# Created Date: 3/24/2015
# http://forums.veeam.com/member31097.html
# 

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

# Names of VMs to backup separated by comma (Mandatory). For instance, $VMNames = “VM1”,”VM2”
$VMNames = "VM1","VM2"

# Name of vCenter or standalone host VMs to backup reside on (Mandatory)
$HostName = "vCENTER.URL"

# Directory that VM backups should go to (Mandatory; for instance, C:\Backup)
$Directory = "\\UNC\PATH"

# Network Credentials for the directory path listed above
$DirectoryCreds = "VEEAM"

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

# Quiesce VM when taking snapshot (Optional; VMware Tools are required; 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 = "In2Weeks"

##################################################################
#                   Notification Settings
##################################################################

# Enable notification (Optional)
$EnableNotification = $True

# Email SMTP server
$SMTPServer = "smtp.URL"

# Email FROM
$EmailFrom = "email@address.com" 

# Email TO
$EmailTo = "email@address.com"

# Email subject
$EmailSubject = "Veeam Free Backup Report"

##################################################################
#                   Email formatting 
##################################################################

$style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 5px; }"
$style = $style + "</style>"

##################################################################
#                   End User Defined Variables
##################################################################

#################### DO NOT MODIFY PAST THIS LINE ################
Asnp VeeamPSSnapin

$NetCreds = Get-VBRCredentials -Name "$DirectoryCreds"
$Server = Get-VBRServer -name $HostName
$MesssagyBody = @()

foreach ($VMName in $VMNames)
{
  $VM = Find-VBRViEntity -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 -NetworkCredentials $netcreds
  }
  
  Else 
  {
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention -NetworkCredentials $netcreds
  }
  
  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,@{n="Details";e={($TaskSessions | sort creationtime -Descending | select -first 1).Title}})
  }
  
  }   
}
If ($EnableNotification)
{
$Message = New-Object System.Net.Mail.MailMessage $EmailFrom, $EmailTo
$Message.Subject = $EmailSubject
$Message.IsBodyHTML = $True
$message.Body = $MesssagyBody | ConvertTo-Html -head $style | Out-String
$SMTP = New-Object Net.Mail.SmtpClient($SMTPServer)
$SMTP.Send($Message)
}


Post Reply

Who is online

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