Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

VMware Backup with PowerCLI and Veeam

Posted on July 7, 2010

My primary backup drive for my virtual machine backup toasted on me so I had to recreate all of my backup jobs. I’ve been using Veeam’s backup product for VMware and it couldn’t be easier to use. I’ve known that it included a set of PowerShell cmdlets but I had never really looked at them before.  I decided this would be a great opportunity.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

One of my backup goals, that I’ll describe today, was to grab all VMs in a particular datastore and backup them up to a local external drive. The current version of Veeam doesn’t allow you to specify a datastore as a container. Although I didn’t use it, you are supposed to be able to specify an ESX host, which will back up all machines. Or you need to specify a comma separated list of virtual machines. In my case, I wanted all VMs on datastore2. But what are they? PowerCLI to the rescue. First off, your VM host must be connected and not in maintenance mode. For my purposes, I like having the virtual machines themselves powered off. Using Get-VM I can find all machines on the required datastore.

PS C:\> get-vm -Datastore datastore2

Name                 PowerState Num CPUs Memory (MB)
----                 ---------- -------- -----------
MyCompany Windows 7  PoweredOff 1        512
R2 Core RODC         PoweredOff 1        1024
MyCompany Vista      PoweredOff 1        768
MyCompany XP         PoweredOff 1        384
MyCompany2003        PoweredOff 1        384
Research Member S... PoweredOff 2        1024

All I need are the names so I pop them into a variable.

PS C:\> get-vm -Datastore datastore2 | foreach {$v+=$_.name}
PS C:\> $v
MyCompany Windows 7
R2 Core RODC
MyCompany Vista
MyCompany XP
MyCompany2003
Research Member Server R2

Armed with this I can now invoke the Add-VBRBackupJob cmdlet from Veeam.

PS C:\> Add-VBRBackupJob -Name "Dstore2_Backup" -Type VDDK –mode "san;nbd" –Folder "g:\datastore2" -objects $v -host "My Computer" –FileName "dstore2"

This command will create a backup job called Dstore2_Backup using the VMware vStorage API to backup all VM objects to G:\Datastore2 on “My Computer”.  As I continue to poke around with these cmdlets, I’ll be sure to share.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

4 thoughts on “VMware Backup with PowerCLI and Veeam”

  1. Pingback: Tweets that mention VMware Backup with PowerCLI and VeeamThe Lonely Administrator | The Lonely Administrator -- Topsy.com
  2. Carter Shanklin says:
    July 7, 2010 at 7:35 pm

    Do the Veeam cmdlets accept objects rather than strings? @veeam if they don’t, they should! Could would be a lot cleaner.

    1. Jeffery Hicks says:
      July 7, 2010 at 8:23 pm

      Not really. In my example, $v is an array of strings but the cmdlet handles it just fine. I’m not sure what other types of objects the Veeam cmdlets could recognize. I’ll have to continue kicking this stuff around.

  3. Pingback: Running Veeam JobsThe Lonely Administrator | The Lonely Administrator

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d