Solved

Veeam Start-VBRZip powershell script (ET)

Posted on 2016-10-11
10
231 Views
Last Modified: 2016-10-19
I am trying to write a powershell script to perform VeeamZIP on certain VMs. This article explains how to do it (page 746) but i cannot seem to get it right because i keep getting errors with my syntax.
https://www.veeam.com/pdf/guide/veeam_backup_9_0_powershell_reference_en.pdf

This is what i wrote so far:
Add-PSSnapin VeeamPSSnapin
$ServerName = Find-VBRHvEntity -Server localhost -Name 'OSNY2k12PS01'
Start-VBRZip -Folder "D:\VMBackup" -Entity $ServerName -Compression 5 -DisableQuiesce -AutoDelete In1Week

Open in new window


Also i have about 10 vms that i want to run this on. Can i combine them all into one script so it starts the next server when the previous one finishes.
0
Comment
Question by:tabush
  • 6
  • 4
10 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 41838728
I'd suggest checking out this blog.  There are a couple sample scripts (for Hyper-V and VMWare) at the bottom of the page you can download (and I have used, at least the VMWare one).  You can supply the names of multiple VMs and it will loop through them.

Just looking at your commands above, I don't see any problem.  You may want to verify that your Find-VBRHvEntity command returns the right object.  Other that than, you'd have to show which errors you're getting.  But the sample scripts are your best bet.
1
 
LVL 2

Author Comment

by:tabush
ID: 41838738
Which blog are you referring to? Think you forgot to post the link.
0
 
LVL 40

Assisted Solution

by:footech
footech earned 500 total points
ID: 41838842
Damn.  I thought you could see my screen...
:)

Sorry about that.
https://www.veeam.com/blog/veeam-backup-free-edition-now-with-powershell.html
1
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 2

Author Comment

by:tabush
ID: 41842479
In the script it asks to specify
"Name of vCenter or standalone host VMs to backup reside on"
What would the name of my vCenter be? I dont want to specify host because i have more than one.
Would it be the IP or one of the names below that?

2016-10-13-14_38_27-osny2k12bkup01.n.png
0
 
LVL 2

Author Comment

by:tabush
ID: 41842571
I tried it with NYC ESX and this is the error im getting:

At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:21 char:2
+ - High, 9 - Extreme)
+  ~
Missing expression after unary operator '-'.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:21 char:3
+ - High, 9 - Extreme)
+   ~~~~
Unexpected token 'High' in expression or statement.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:21 char:7
+ - High, 9 - Extreme)
+       ~
Missing argument in parameter list.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:21 char:20
+ - High, 9 - Extreme)
+                    ~
Unexpected token ')' in expression or statement.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:117 char:101
+ ... | select -first
+                    ~
Missing closing ')' in expression.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:119 char:1
+ 1).Title}})
+ ~
Unexpected token '1' in expression or statement.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:117 char:38
+ {$_.EndTime}},Result,@{n="Details";e={($TaskSessions | sort creationtime -Descen ...
+                                      ~
Missing closing '}' in statement block.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:119 char:2
+ 1).Title}})
+  ~
The hash literal was incomplete.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:79 char:1
+ {
+ ~
Missing closing '}' in statement block.
At C:\Users\networkadmin\Desktop\VeeamZIP.ps1:119 char:11
+ 1).Title}})
+           ~
Unexpected token ')' in expression or statement.
Not all parse errors were reported.  Correct the reported errors and try again.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

and in the script that i wrote (posted above) this is the error i was getting:

Find-VBRHvEntity : Cannot process argument transformation on parameter 'Server'. Host with name 'localhost'
was not found
At C:\Users\networkadmin\Desktop\Veeam Backup Script.ps1:2 char:40
+ $ServerName = Find-VBRHvEntity -Server localhost -Name 'OSNY2k12PS01'
+                                        ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Find-VBRHvEntity], ParameterBindingArgumentTransformationExc
   eption
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Veeam.Backup.PowerShell.Command.FindVBRHv
   Entity
 
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\networkadmin\Desktop\Veeam Backup Script.ps1:3 char:44
+ Start-VBRZip -Folder "D:\VMBackup" -Entity $ServerName -Compression 5 -DisableQu ...
+                                            ~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Start-VBRZip], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Commands.Backup.Start
   VBRZip
0
 
LVL 40

Expert Comment

by:footech
ID: 41842641
In your screenshot above, it looks like your vCenter would be the 192.168.x.x address.  Below that is the Datacenter, Cluster, then hosts.

Make sure to use the hostname as you see it in Veeam (I think it's always the full FQDN).

Looks like all those errors are likely from a poor copy and paste of the script, or maybe editing with something that changed the file, or a missing quote.

Lastly, are you backing up Hyper-V or VMWare?  Make sure you're using the right cmdlet for each.
0
 
LVL 2

Author Comment

by:tabush
ID: 41843817
I downloaded the script straight to the server this time so no copy-pasting but getting a different error now.
It seems that its not recognizing the $server variable

Find-VBRViEntity : Cannot validate argument on parameter 'Server'. The argument is null. Provide a valid
value for the argument, and then try running the command again.
At C:\Users\networkadmin\Downloads\VeeamZIP-VI-updated\VeeamZIP (VI - updated).ps1:76 char:48
+   $VM = Find-VBRViEntity -Name $VMName -Server $Server
+                                                ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Find-VBRViEntity], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.FindVBRViEnti
   ty
 
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\networkadmin\Downloads\VeeamZIP-VI-updated\VeeamZIP (VI - updated).ps1:86 char:40
+     $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $Comp ...
+                                        ~~~
    + CategoryInfo          : InvalidData: (:) [Start-VBRZip], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Commands.Backup.Start
   VBRZip
0
 
LVL 40

Expert Comment

by:footech
ID: 41844441
Is the $Hostname variable set correctly for your environment?  Make sure the following line returns info.
Get-VBRServer -name $HostName

Open in new window

The script uses that to set the $server variable.  And then that is used in the next command.
Find-VBRViEntity -Name $VMName -Server $Server

Open in new window

Running that command manually should also return info.
0
 
LVL 2

Author Comment

by:tabush
ID: 41850611
Sorry for the delayed response. Yes that command worked.
I also did ECHO $HostName
and it did output the correct hostname that i entered.
0
 
LVL 2

Assisted Solution

by:tabush
tabush earned 0 total points
ID: 41850633
Think i figured it out!
For hostname i had to enter the IP address because that's how we have it listed within Veeam.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question