Backup your VMware firmware / configuration


Userlevel 7
Badge +14

Hi all,

 

for those who want to create a backup of their VMware host configurations, I have created a simple script that uses the PowerCLI to create a backup of your host config.

 

You can find the module here: https://github.com/mkevenaar/Veeam/tree/main/VMware

 

This module allows you to export host configurations (HostFirmware) of all your VMHosts in your vCenter environment.

This requires VMware.PowerCLI. Easy to install using Chocolatey

choco install vmware-powercli-psmodule

example usage

Make changes to settings.ps1 as required, multiple vCenter servers are supported

Import-Module c:\Path\To\VMware.Backup.psm1
Get-Backups

 

You can change the location where to store the backups in the settings.ps1 file, location is up to you as long as the user executing the script has access to that folder. You can use a Backup Copy Job or the backup of the VM to make extra copies of your host configs.

Obviously, make sure that you do not store the data on the same VMware hosts as you are backing up.

Restore

 

Currently I do not have a PowerShell script to restore. (I will create that one day). However this should work:

Add the host to the vCenter Server using your normal methods

Change the commands below to your needs and execute these in the PowerCLI window

Connect-VIserver -Server myvcenter.mydomain.tld -Protocol "https" -User "myuser" -Password "mypassword"

Set-VMHost -VMHost myhost.mydomain.tld -State "Maintenance"

Set-VMHostFirmware -VMHost myhost.mydomain.tld -Restore -Force -SourcePath c:\backup\VMware\myvcenter.mydomain.tld\mydc1\configBundle-myhost.mydomain.tld.tgz 

 

More info on used commandlets:

https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/connect-viserver/

https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/get-vmhost/

https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/set-vmhost/

https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/get-vmhostfirmware/

https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/set-vmhostfirmware/


6 comments

Userlevel 7
Badge +20

I truly love things like this to make automation easier.  Especially backing up VMware stuff and PowerCLI.  Love PS!! 😎

Userlevel 7
Badge +6

Looks awesome…only suggestion is that if storing a password, I’d recommend storing it as a secured string.  I’ve only done this once a couple years ago so I don’t recall the exact syntax for doing this, but it looks like this link has some info on it.

https://www.pdq.com/blog/secure-password-with-powershell-encrypting-credentials-part-1/

 

Userlevel 7
Badge +6

I truly love things like this to make automation easier.  Especially backing up VMware stuff and PowerCLI.  Love PS!! 😎

 

PowerCLI is the bomb…..we used it at my old job for automating DR failover. 

As a bit of background, we had EMC RecoverPoint Appliances that would split data between our primary storage and the storage at our DR location.  When we paused replication and presented the datastores to the hosts.  We then used PowerCLI to rescan the storage adapters, mount all of the datastores, resignature the LUN’s, scan the datastores for the .vmx files and register the VM’s to the hosts, power on the VM’s, and answer the “did you copy or move” questions.  It was a very manual process that took a fair amount of time to do.  Automating it with PowerCLI took what may have been an hour long process to about 10 or 15 minutes.

Userlevel 7
Badge +14

Looks awesome…only suggestion is that if storing a password, I’d recommend storing it as a secured string.  I’ve only done this once a couple years ago so I don’t recall the exact syntax for doing this, but it looks like this link has some info on it.

https://www.pdq.com/blog/secure-password-with-powershell-encrypting-credentials-part-1/

 

Yeah, I agree there should be encrypted passwords. However this is just one way that you could use it. 

 

If you have an improvement, feel free to send a PR to the repository

Userlevel 7
Badge +6

Guess I need to learn git now?  Or github now?  Not sure what the proper verb is...it’s all so new to me.

Userlevel 7
Badge +14

Guess I need to learn git now?  Or github now?  Not sure what the proper verb is...it’s all so new to me.

Basically Git is the version control software, where GitHub is the (web) interface used for visualizing and managing your Git actions (there is more to GitHub than just that, but let's not go that deep into the matter just yet) 

Comment