Start-VBRZip in Veeam Backup Free Edition

PowerShell script exchange

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Wed Aug 02, 2017 10:39 am

I have create a very simple powershell script as a test to backup for now but it seems to ignore the -AutoDelete

Try to set retention via GUI and open a support ticket if the problem is reproduced. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Wed Aug 02, 2017 1:04 pm

I use Veeam Backup & replication for Hyper-V 9.5 free edition with the standart Power Shell script. With this script i can specify VMs that i want to back up, VMs have a couple of vhdx disk but i need to exclude one of vhdx. How can i establish it via Power Shell? Thanks.

You cannot exclude disks from processing in VB&R Free edition. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby amatthews » Thu Aug 03, 2017 3:59 pm

proactis wrote:I have create a very simple powershell script as a test to backup for now but it seems to ignore the -AutoDelete and seems to delete the day after. Is there a way of seeing what veema has issued to the zip backup as retention policy

$VM = "Server1"
$BackupPath = "E:\backup\"
Start-VBRZip -Entity $VM -Folder $BackupPath -Compression 9 -AutoDelete In3Days


Hi
I had a similar problem to this myself and its all to do with how dates are handled in Veeam.

If you have a look in the task log file, you will see an entry similar to this: -
[29.07.2017 07:59:05] <15> Info [VeeamZIPRetention] Create, id 'GUID', retain days '08/05/2017 00:00:00',


As you can see, you have the date in the log file that the task started on 29.07.2017. My job was set to retain for 1 week which should mean it is retained until '05/08/2017'. What is recorded in the system for retention is '08/05/2017' which the system will see as being past it's retention date and will delete the file.

To prove this, I did another backup with a retention date of 1 month. The log file is as follows: -
[03.08.2017 16:47:39] <15> Info [VeeamZIPRetention] Create, id '5948ba75-32c5-40ce-97ae-2c9b38127311', retain days '09/03/2017 00:00:00'

This means that the backup will be detected on the system as being out of date as it's scheduled to be deleted on the 9th March 2017.

This is a bug in Veeam that needs to be logged with them.
amatthews
Lurker
 
Posts: 2
Liked: never
Joined: Thu Aug 03, 2017 1:47 pm
Full Name: Andrew Matthews

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby amatthews » Thu Aug 03, 2017 4:23 pm

proactis wrote:I have create a very simple powershell script as a test to backup for now but it seems to ignore the -AutoDelete and seems to delete the day after. Is there a way of seeing what veema has issued to the zip backup as retention policy

$VM = "Server1"
$BackupPath = "E:\backup\"
Start-VBRZip -Entity $VM -Folder $BackupPath -Compression 9 -AutoDelete In3Days


I saw a similar problem to this myself and I think it's to do with the way the retention date is recorded. If you look in the Task file for your backup, you will see a line similar to this: -
[29.07.2017 07:59:05] <15> Info [VeeamZIPRetention] Create, id '{GUID}', retain days '08/05/2017 00:00:00', repository id '00000000-0000-0000-0000-000000000000', target file '{File Name}'


As you can see, the retain days date is recorded in the format mm/dd/yyyy.

Overnight, the Service Backup process kicked in and deleted the file as it was past it's retention and was recorded in the log file as this: -
[30.07.2017 00:00:05] <30> Info [VeeamZIPRetention] Deleting file '{File Name}' on repository 'Local filesystem' because it's due is 08/05/2017 00:00:00


To prove my theory, I've just run a backup with a 1 month retention and the log file is shown as this: -
[03.08.2017 16:47:39] <15> Info [VeeamZIPRetention] Create, id '{GUID}', retain days '09/03/2017 00:00:00', repository id '00000000-0000-0000-0000-000000000000', target file '{File Name}'


The retain date has been recorded again in mm/dd/yyyy format instead of dd/mm/yyyy so I would expect the backup file to be deleted overnight as it's past it's expiry date.

I've logged this with Veeam - let's see what comes out of it.
amatthews
Lurker
 
Posts: 2
Liked: never
Joined: Thu Aug 03, 2017 1:47 pm
Full Name: Andrew Matthews

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby r.castello » Fri Aug 04, 2017 9:46 am

v.Eremin wrote:Everything is working fine except Retention, this is set to "Tonight" for testing and backups are not deleted.
Can you try to reproduce the issue via GUI and provide me with the results of your findings?

Hello Again v.Eremin,

I'm having issues another time with Retention Policy, I will show you an example.
Here's the script I use for multiple jobs with VeeamZip powershell script, as you can see in this case we are backing up a virtual machine called dnscache12 with a RetentionPolicy of 3 days.

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 = "dnscache12"

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

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

# 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 = $True

# 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 = "In3days"

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

# Enable notification (Optional)
$EnableNotification = $false

# Email SMTP server
$SMTPServer = ""

# Email FROM
$EmailFrom = ""

# Email TO
$EmailTo = ""

# Email subject
$EmailSubject = "VeeamZip - dnscache"

##################################################################
#                   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

$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
  }
 
  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,@{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)
}



As you can see in the next code, is the event generated on windows Event log as backup is completed successfully, on Veeam Backup there is the same record.

Code: Select all
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Veeam Backup" />
  <EventID Qualifiers="0">0</EventID>
  <Level>4</Level>
  <Task>0</Task>
  <Keywords>0x80000000000000</Keywords>
  <TimeCreated SystemTime="2017-08-03T18:02:01.000000000Z" />
  <EventRecordID>7415</EventRecordID>
  <Channel>Veeam Backup</Channel>
  <Computer>wingest01</Computer>
  <Security />
  </System>
- <EventData>
  <Data>Session dnscache12_2017-08-03T200011 (Active Full) has been completed.</Data>
  </EventData>
  </Event>


But a little bit later, just 4hours later and not 3 days as specified on RetentionPolicy backup is deleted!!

Code: Select all
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Veeam MP" />
  <EventID Qualifiers="0">10050</EventID>
  <Level>4</Level>
  <Task>0</Task>
  <Keywords>0x80000000000000</Keywords>
  <TimeCreated SystemTime="2017-08-03T22:00:21.000000000Z" />
  <EventRecordID>7462</EventRecordID>
  <Channel>Veeam Backup</Channel>
  <Computer>wingest01</Computer>
  <Security />
  </System>
- <EventData>
  <Data>14d5dd8c-ba2e-4dd4-bcce-5fbd424011a8</Data>
  <Data>14d5dd8c-ba2e-4dd4-bcce-5fbd424011a8</Data>
  <Data>vm-1795</Data>
  <Data>dnscache12</Data>
  <Data>vcenter.XXXXXXX</Data>
  <Data>08/03/2017 22:00:21</Data>
  <Data>False</Data>
  <Data>0</Data>
  <Data />
  <Data />
  <Data />
  <Data />
  <Data />
  <Data />
  <Data />
  <Data />
  <Data />
  <Data />
  <Data>1</Data>
  <Data>Restore point for VM 'dnscache12' has been removed according to the configured retention policy.</Data>
  </EventData>
  </Event>


Any ideas on what's happening?
Something that it's strange for me is that folder "$Directory = "D:\VeeamBackup_vcenter5\dnscache"" is gone, "dnscache" folder does not exist anymore. So maybe retention policy is deleting old backup(>3days) but it wipes all the folder with the new ones.
r.castello
Novice
 
Posts: 3
Liked: never
Joined: Wed Jul 12, 2017 10:31 am
Full Name: Ruben

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Fri Aug 04, 2017 4:28 pm

The best course of action is the following:

- Try to apply the retention period via GUI
- If the issue is reproduced, log a support ticket
- Post the case its number here, and we will follow the case

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby manticore01 » Mon Aug 07, 2017 1:31 pm

Hi All,

Was writing this post as i could not work out what was going wrong, as i got to the end it all clicked. I thought id still post this for anyone else that may get stumped before the coffee kicks in.

I could not pass the -NetworkCredentials parameter in the way the documentation states. "Get-VBRCredentials" was returning a string array which isnt passable to Start-VBR as it expects CCredentials type.

Code: Select all
$VM = Find-VBRViEntity -Name $VMName -Server $Server
$netcreds = Get-VBRCredentials -Name "test"

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


The above code gave me the following error:

Start-VBRZip : Cannot convert 'System.Object[]' to the type 'Veeam.Backup.Common.CCredentials' required by parameter 'NetworkCredentials'. Specified method is not supported.

Turns out, if you have multiple credentials with the same username, it falls apart as Get-VBRCredentials return a list of them rather than the CCredential type.
I had a standard credential, and also a linux credential with the same username (as VBR made me create a different one for use with a Linux file store).

So for anyone that searches the above error message i originally got, they should hopefully find this.

Quick additional note, I had looked at the documentation https://helpcenter.veeam.com/docs/backup/powershell/start-vbrzip.html and couldnt see anything different. It may also be worth noting on that page theres a typo in the very last code snippet (theres a & instead of an $) NetworkCredentials &netcreds -RunAsync.

Thanks all!
manticore01
Lurker
 
Posts: 1
Liked: never
Joined: Mon Aug 07, 2017 12:44 pm

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Tue Aug 08, 2017 1:17 pm

Thank you, the information has been passed to technical writers already.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Previous

Return to PowerShell



Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests