Latest posts by Vladan Seget (see all)
- Top 5 tips for VMware virtualization-based security - Wed, Sep 11 2019
- VMware VM Hot Add: Changing VM hardware on a running vSphere VM - Fri, Aug 30 2019
- What is the VM Overrides option and how do you use it? - Fri, Aug 16 2019
Note: You can also back up and restore ESXi host configurations with the vSphere Command-Line Interface (vSphere CLI or vCli). This VMware KB article explains the details.
If you want to perform a backup with PowerCLI, you first have to download the module from VMware to your management machine. If you don't have a My VMware account, you can create one for free.
After you install the PowerCLI module, you can connect to your host with the following command. Replace the IP address with that of your ESXi host.
It will prompt you for your username and password unless your ESXi host and your management machine are Active Directory domain members. Of course, your account requires sufficient privileges to connect. Note that you might get a yellow text warning about invalid certificates unless you're using your own, not the self-issued certificate from VMware.
Then you have to execute this command:
Get-VMHostFirmware -VMHost ESXi_host_IP_address -BackupConfiguration -DestinationPath output_directory
ESXi_host_IP_address is the IP address of the ESXi host and output_directory is the name of the directory where it will create the output file.
Here is an example from my lab:
get-vmhost | get-vmhostfirmware -BackupConfiguration -DestinationPath "C:\Download"
Note: You must create the C:\Download folder manually before executing the command.
Now you can check the download folder to ensure the backup file exists. It should look have the extension .tgz and start with "configBundle."
What does the backup file contain? ^
The backup file is compressed. You can extract it with a tool like 7‑Zip, which handles .rar and .tgz extensions. The information in the backup file is quite comprehensive. It contains many small configuration files, SSL certificates, storage configurations, iSCSI settings, VMware cluster configurations, and so on.
How to restore the configuration ^
If you want to restore a previously backed-up configuration to an ESXi host, the host has to be reachable over the network. Thus, if you installed a new host, you have to configure the network settings at least before you can restore the backup.
First you have to put your host into a maintenance state via the vSphere client or with this PowerCLI command:
Set-VMHost -VMHost 10.10.5.11 -State "Maintenance")
After that, you can back up your host with this command:
Get-VMHost "10.10.5.11" | Set-VMHostFirmware -Restore -DestinationPath "C:\Download"
If you're restoring to different hardware or a different build, you might need to add the "force" switch:
Get-vmhost "10.10.5.11" | Set-VMHostFirmware -Restore -Force ‑DestinationPath "C:\Download"
That's basically it. Note that the host will reboot after applying the new configuration.
What if VMs were registered on the host? ^
In case virtual machines were running on this ESXi host, you'll have to register them again by using the datastore browser. After you right-click the VMX configuration file, you'll see the option Add to Inventory. The backup does not store information about VMs; thus, you'll need to re-inventory them.
The backup process described in this post can be useful for small environments where you want to secure the configurations of individual hosts. However, for large environments and for networks with Enterprise Plus licenses, you'd probably use VMware Host Profiles to maintain a homogenous configuration across all of your hosts. You'll probably also be using Auto Deploy and stateful or stateless options to maintain your hosts without the need to maintain the configuration at the host level.