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:
Set-ExecutionPolicy RemoteSigned
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..
Restore operations
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.
Feel free to subscribe via RSS or follow on Twitter (@vladan)
Jay says
Hi, Thanks for posting these commands. In a new environment this is really helpful to have a baseline to restore from. However, in my tests I noticed that it restored VMs that were present on the host at the time the backup was taken. Is there a way to exclude the backup from taking the VM list? When I restored a host after moving VMs around I noticed there were several ghost VMs. I know I could probably edit the vminventory file to remove the VM lists but it would be handy and save sometime to exclude the VMs, in case I just wanted to restore one host. Thank you.
rl says
Hello Vladan,
Thanks very much for this posting and commands. Was very useful in migrating between USB sticks. Saved me a lot of time and I got to use PowerCLI for the first time.
Thanks again!
-R
Vladan SEGET says
Thanks for reading our blog. You’re welcome. Glad it helped.. -:)
James says
Hi Vladan. Will this restore even vSAN configurations?
Thanks
James
Vladan SEGET says
I don’t think so… and certainly unsupported…
Richard Johnson says
Hi
What does this actually backup? e.g. IP details? vSwitch details? NTP? advanced config such as scratch location? syslog location?
Kevin says
Is it possible to restore a ESXI 6.x Backup to the same host with a fresh install of ESXI 5.5?
Alok says
I also am trying to format a host and the vsan so i have made the backup of the configuration, i wish to restore the ESXi host as it was maybe without the vSan as i would rebuild it anyhow.
If you know a fresh installed ESXi can be restored with this config file please reply.
Maria says
Hello,
Does this support vsphere 6.0?
Thank you
marcus wessberg says
Really good, thank you for sharing
Richard Hughes says
Does this do the VIBs also?
Vladan SEGET says
No, just the config. It’s not any kind of “image” backup. Saves time to reconfigure, when your USB stick fails.