In some situations you might need to backup or restore configuration of your ESXi host. This can be done with several tools with GUI front end or you can use tools diretly built-in ESXi and vSphere. And that's what we will explore today.
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. Scripting guys calls it one-liner…
Backup and Restore ESXi Configuration with PowerCLI, the steps:
Open PowerCLI > Connect to vCenter with Connect VI-Server command and 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:
Only after you can enter the backup command:
get-vmhost | get-vmhostfirmware -BackupConfiguration -DestinationPath “C:\Download”
This suppose that you create the c:Download folder before executing this…
You'll get four files in a c:\download folder…
Nice isn't it..
02. 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 esxi5-03.lab.local -State “Maintenance”
As you can see it's possible to use FQDN, IP or hostname.
03. 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).
So in my example:
As you can see it's an easy way to backup and restore configuration of your ESXi hosts.