PowerShell script exchange
Post Reply
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Does anybody know why it would suddenly have started deleting the backups from the previous night?
Kindly, check the answers provided above. It's a known issue that retention policy does not work as expected. According to the plan, it will be fixed in Update 3.
r.castello
Influencer
Posts: 11
Liked: never
Joined: Jul 12, 2017 10:31 am
Full Name: Ruben
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by r.castello »

Sorry for the delay on my response, I have been out for 1 month. Yes, raised a ticket yesterday and got similar answer as you, this will be fixed in next update so we will wait and try to apply some workaround meanwhile. Can you give use some ETA on Update 3?

Thanks for the support given here.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Somewhere in October (though, it's still an unofficial date). Thanks.
proactis
Novice
Posts: 3
Liked: never
Joined: Jun 14, 2011 9:41 am
Contact:

[MERGED] Start-VBRZip Options deletes backiup

Post by proactis »

I have created a powershell script to backup my virtual machines but when I use any of these options with in the script. I find that it has deleted them in the morning is this a known issue?

Tonight
TomorrowNight
In3days
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Known issue that should be addressed in Update 3. Thanks.
proactis
Novice
Posts: 3
Liked: never
Joined: Jun 14, 2011 9:41 am
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by proactis »

I'm using 9.5 version is that still true?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Correct. The latest available update for 9.5 is Update 2. Update 3 for 9.5 is yet to see the light.
blmey
Lurker
Posts: 1
Liked: never
Joined: Oct 31, 2017 7:11 pm
Full Name: Blake Meyer
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by blmey »

Case # 02365261 I tried running the script provided by Vladimir Eremin. I am trying to run a backup from one command and keep running into this error, I've scrolled through other post but haven't seen a definitive answer as to why it's not running succesfully. any help would be appreciated. I'm running windows server 2016 with version 5 powershell.




Start-VBRZip : Cannot validate argument on parameter 'Entity'. The argument is null. Provide a valid value for the argument, and then try running the
command again.
At C:\Users\su_bmeyer\Desktop\veeamhv.ps1:86 char:40
+ $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compre ...
+ ~~~
+ CategoryInfo : InvalidData: (:) [Start-VBRZip], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.StartVBRZip

You cannot call a method on a null-valued expression.
At C:\Users\su_bmeyer\Desktop\veeamhv.ps1:91 char:5
+ $TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog().upd ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull



fulls script is here.

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 = "itiWSUS.impacttech.com"

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

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

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

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

# Enable notification (Optional)
$EnableNotification = $True

# Email SMTP server
$SMTPServer = "ITIExch10v.impacttech.com"

# Email FROM
$EmailFrom = "veeambackuptest@testcenter.com" 

# Email TO
$EmailTo = "blakem@impacttech.com"

# Email subject
$EmailSubject = "backup test"

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

$style = "<style>hello this is a test{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1020px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1020px solid black; background: #dddddd; padding: 1020px; }"
$style = $style + "TD{border: 1020px solid black; padding: 50px; }"
$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-VBRHvEntity -Name $VMName  
  
  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)
}
alecnaylor
Novice
Posts: 4
Liked: never
Joined: Jul 21, 2017 10:24 am
Full Name: Alec Naylor
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by alecnaylor »

v.Eremin wrote:UPDATE: the given problem with retention policy should be fixed in Update 3. Thanks guys for actively raising this issue, your participation allowed us to identify the root cause of the problem and react accordingly; much appreciated.
Is there any news on the problem with the retention policy in Veeam Backup and Replication Free software? It was mentioned that this bug would be fixed in Update 3. It is not showing in the update section on the veeam site yet. Does anyone know when it might be released?
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Vitaliy S. »

Hi Alec, Update 3 should be released in this quarter, stay tuned. Hope this helps!
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

I am trying to run a backup from one command and keep running into this error, I've scrolled through other post but haven't seen a definitive answer as to why it's not running succesfully.
$VM variable does not contain anything, as the result the script fails. Check whether the variable gets assigned properly. Thanks.
bobspadger
Lurker
Posts: 2
Liked: never
Joined: Dec 06, 2017 9:37 am
Full Name: Alex Hellier
Contact:

[MERGED] Veeam Free Powershell Script removing all backups

Post by bobspadger »

Hi All

I've started trialling veeam free using the powershell script provided on their blog.

This is triggered via a task scheduler job and the backups complete successfully and I get emailed completion and success.

However, when I go to check the backup location to see that the files are all present and correct, the directory is empty.

I've attempted to increase the retention time in the script but this does not appear to have any effect.


Any ideas ?

Thanks in advance.

Alex
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

There is a known issue with how retention policy gets applied via PS. Kindly, wait till Update 3 is released, since it has this problem resolved. Thanks.
bobspadger
Lurker
Posts: 2
Liked: never
Joined: Dec 06, 2017 9:37 am
Full Name: Alex Hellier
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by bobspadger »

Thanks for the reply.

Do you have an ETA for Update 3?

Thanks
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Should be released within several weeks. Thanks.
lext55
Novice
Posts: 3
Liked: never
Joined: Nov 27, 2017 8:53 am
Full Name: Andrey Sharov
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by lext55 »

STEP by STEP HOW-TO INSTRUCTION VeeamZIP PowerShell

Host Machine: Microsoft 2012 R2 Core Server Eng x64 (Standalone) WORKGROUP
Veeam Backup & Replication: 9.5.0.1038 Free Edition
Backup server: Synology DS-414j Domain
Sysadmin PC: Windows 8.1 Eng x64 WORKGROUP
Test virtual machine: Centos 5.11

1. Install Veeam Backup & Replication on server Microsoft 2012 R2 Core Server Eng
https://www.youtube.com/watch?v=o7AdaddP7Uw
2. Download PowerShell script for Hyper-V
https://www.veeam.com/blog/veeam-backup ... shell.html
3. Make directory C:\VeeamZIP . Place the script into this directory. Full path:
C:\VeeamZIP\VeeamZIP.ps1
4. I fill the script variables

Code: Select all

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

# Name of vCenter or standalone host VMs to backup reside on (Mandatory)
$HostName = "SERVER-HYPER-V"

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

# 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 = "In1Month"
5. On sysadmin PC must be installed and configured Hyper-V remote console . On hypervisor server must be enabled Remote management .

On sysadmin PC go to Control Panel → Administrative Tools → Services → Connect to hypervisor host , where was installed Veeam Backup & Replication 9.5.0.1038 → Change Local System Account all Veeam services (9 pcs) on build in Administrator

Image
Image
Image
Image

6. Reboot hypervisor host machine
7. On Synology DS-414j i create a local user (not domain) with a one-to-one name and password both on the virtualization server(User: Administrator Pass: Strong_Password) and grant read / write permissions on targer directory.
8. Connect to hypervisor host machine via RDP . With the help of some file manager ( exp FreeCommander ) check file permissions ( I try to create and delete an empty directory) on UNC way .
9. In cmd run powershell . Run commands

Code: Select all

powershell
cd c:\VeeamZIP
./VeeamZIP.ps1
The backup should complete successfully.
10. Now you need to configure the script to run on the scheduler. I open the console cmd and give commands:

This is the command to create a task in the scheduler

Code: Select all

SCHTASKS /Create /RU Administrator /RP Strong_Password /SC WEEKLY /D FRI /TN VeeamZIP /TR "powershell.exe -file C:\VeeamZIP\VeeamZIP.ps1" /ST 23:00
This command to change the task in the scheduler

Code: Select all

SCHTASKS /Change /TN VeeamZIP /RU Administrator /RP Strong_Password /TR "powershell.exe -file C:\VeeamZIP\VeeamZIP.ps1" /ST 23:00
This command displays information about our task

Code: Select all

SCHTASKS /Query /TN VeeamZIP
Well, run the task through the scheduler immediately.

Code: Select all

SCHTASKS /Run /TN VeeamZIP
11. On server Microsoft 2012 R2 Core management console Veeam Backup & Replication not working. To manage Veeam Backup & Replication from the system administrator's computer, you need to install only the console on this computer Veeam Backup & Replication
P.S.: to Vladimir Eremin , wait new script with -NetworkCredentials in user variables
P.P.S.: Sorry for my English
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Thanks for the detailed instruction, the only portion I don't get is the following one:
P.S.: to Vladimir Eremin , wait new script with -NetworkCredentials in user variables
The said parameter has been already added in Update 2, so, feel free to use it.

Thanks.
r.castello
Influencer
Posts: 11
Liked: never
Joined: Jul 12, 2017 10:31 am
Full Name: Ruben
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by r.castello »

Hi v.Eremin,

Been waiting for months for Update 3 for the fix of the retention policy and now after the update Veeam update when i launch VeeamZip Backup via powershell prompts error "20/12/2017 18:25:54 :: Task failed. Error: Not enough licenses.
". We have 3 hosts licensed and were using VeeamZip for another vmware server. Have been using on update 2 without problems( Except error retention policy ) and now cant backup due to this error. is this a mistake? or something changed in veeam policy?
Same behavior if I launch VeeamZip from GUI
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

We have 3 hosts licensed and were using VeeamZip for another vmware server.
Are those hosts controlled from single backup console?
r.castello
Influencer
Posts: 11
Liked: never
Joined: Jul 12, 2017 10:31 am
Full Name: Ruben
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by r.castello »

v.Eremin wrote: Are those hosts controlled from single backup console?
Hi v.Eremin,

Dont know If I understand you very well.
We have a Windows Server 2012 with Veeam Backup&Replication 9.5 installed on it with console too from where I manage Veeam and I have the powershell too. We have 2 vCenter clusters.

Cluster1 --> 3 Hosts ESXi licensed. Backups using Backups Jobs.
Cluster2 --> 2 Hosts ESXi with a few virtual machines. Not licensed.

We were using VeeamZip to backup manually this few machines from Cluster2, but since the Update 3 we got the error "20/12/2017 18:25:54 :: Task failed. Error: Not enough licenses."

Cluster2 is licensed with VmWare, and as I far as I know, VeeamZip is free to use to backup virtual machines manually. Why this change now?

Of course If i go to general settings --> License, the 3 licenses are assigned to Cluster1.
r.castello
Influencer
Posts: 11
Liked: never
Joined: Jul 12, 2017 10:31 am
Full Name: Ruben
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by r.castello »

Support case opened:
02435643
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Indeed, mentioned changes have been made on purpose and they affect both GUI and PowerShell. Thanks.
r.castello
Influencer
Posts: 11
Liked: never
Joined: Jul 12, 2017 10:31 am
Full Name: Ruben
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by r.castello »

v.Eremin wrote:Indeed, mentioned changes have been made on purpose and they affect both GUI and PowerShell. Thanks.
Don't understand, you mean now VeeamZip is changed intentionally and it's no anymore free to use?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

If backup server has a paid license assigned, VeeamZIPping VM consumes a license slot. Previously that has not been the case.

You can protect those VMs with free backup server, though.

Thanks.
Unit22
Novice
Posts: 3
Liked: never
Joined: Dec 22, 2017 4:14 am
Full Name: Bender B. Rodriguez
Contact:

[MERGED] Start-VBRZip in powershell Job

Post by Unit22 »

Hello!
I'm making a backup for a number of servers and for a number of VMs on each
In that purpose, i have an xml config file and PS script
Script reads an xml and executes Start-VBRZip consequentialy
When number of servers grows, overall time grows respectively
As i know, VEEAM can backup several VMs at the same time, so i rewrite the script and wrap Start-VBRZip in Start-Job:

Code: Select all



$JobScriptTest = {
    param (
    $HostBranch)
    process {
        $Server = Get-VBRServer -Type $($HostBranch.Type) -name $($HostBranch.Name)
        if ($Server -ne $null) {
            foreach ($VMachine in $HostBranch.VM) {
                if ($HostBranch.Type = "HvServer") {
                    $VM = Find-VBRHvEntity -Name $($VMachine.Name) -Server $Server 
                    if ($VM -ne $null) {
                         $ZIPSession = Start-VBRZip -Entity $VM -Folder $($VMachine.BackupPath) -Compression $($VMachine.Compression) -DisableQuiesce:(![Bool]($VMachine.Quiescence))
                    }
                }
            }
        }

    }
}

get-job | Remove-Job

[xml]$hosts = Get-Content -Path "C:\scripts\VirtualMachinesTest.xml" -encoding utf8
foreach ($hst  in $hosts.Hosts.Host) {
    Start-Job -InitializationScript {Asnp VeeamPSSnapin} -ScriptBlock $JobScriptTest -ArgumentList $hst -name "Job$($hst.name)"
}

When the script runs, Start-VBRZip starts only in the first PS Job, the others just reports they finished correctly.
Tests show that only Start-VBRZip doesn't work, Get-VBRServer and Find-VBRHvEntity works fine in jobs

How can i solve this prblem?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Before we start discussing the actual script, may I know what kind of license do you have? Free or paid one? Thanks.
Unit22
Novice
Posts: 3
Liked: never
Joined: Dec 22, 2017 4:14 am
Full Name: Bender B. Rodriguez
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Unit22 »

I have a free license. This behavior depends on license type?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Correct, with free edition you cannot create single VeeamZIP backup of multiple VMs. This limitation applies to both GUI and PowerShell. Thanks.
Unit22
Novice
Posts: 3
Liked: never
Joined: Dec 22, 2017 4:14 am
Full Name: Bender B. Rodriguez
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Unit22 »

Hmm, i don't need sngle VeeamZip of multiple VM
I mean - i want to start a number of simultaneous VeeamZip jobs (wrapped in Powershell Job)

If i start several Windows Scheduled Jobs, i can see several VeeamZip jobs running at the same time, but i can't get this result with PowerShell Job (start-job)
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Then, try to write a cycle within which VeeamZIP VMs one by one, and use -RunAsync switch, so that script doesn't wait till the previous backup session is over, before it starts a new one. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests