In some situations you might need to backup or restore configuration of your ESXi host. This can be done with several tools, you can use tools directly built-in ESXi and vSphere. And that’s what we will explore today.
To synchronize the configuration changed with persistent storage, run this command:
vim-cmd hostsvc/firmware/sync_configTo backup the configuration data for an ESXi host, run this command:vim-cmd hostsvc/firmware/backup_configNote: The command should output a URL in which a web browser may be used to download the file. The backup file is located in the /scratch/downloads directory as configBundle-HostFQDN.tgzYou can access the Host using any Secure copy tools like Filezilla to get the file from the above path.
Note: When restoring configuration data, the build number of the host must match the build number of the host that created the backup file.
3.Note: Executing this command will initiate an automatic reboot of the host after command completion
There might be a situation where the only choice is what you already have on a system which manages the environment and you don’t always get the rights to install an additional utility. So PowerCLI to the rescue.
PowerCLI is one of the tools that are bundled for free with vSphere environment, and should always be installed on the management station or on vCenter (if Windows based). You can download latest PowerCLI here. Now, the process of backing up and restoring the configuration of ESXi is fairly simple.
Open the power CLI interface:
Connect to vCenter with Connect-VIServer command
enter this single line to backup the configuration of all the hosts that are attached to vCenter server. Note that during first connection you’ll have to enable remote signing of scripts with a command:
Set-ExecutionPolicy RemoteSigned
Only after you can enter the backup command:
get-vmhost | get-vmhostfirmware -BackupConfiguration -DestinationPath “C:\Hosts”
Here, I have only one connected host to my vCenter Cluster, so the command output is one backup file for one existing host.
Now, if you need to restore a host’s configuration, you need to put the host into maintenance mode first.
You can do it through the GUI or through the PowerCLI so in my example I enter this:
Set-VMHost -VMHost <IP_or_FQDN> -State “Maintenance”
As you can see it’s possible to use FQDN, IP or hostname.
Enter the restore command:
Set-VMHostFirmware -VMHost <IP_or_FQDN> -Restore -Force -SourcePath
The host will reboot immediately after you hit the enter key. (without prompt). As you can see it’s an easy way to backup and restore configuration of your ESXi hosts.
For more details about ESXi Host Backup and Restore Operations, please refer to the below KB