Saturday, August 27, 2016

Backup and Restore ESXi Host Configuration

Backup and Restore ESXi Host Configuration


Todays post involves something I havent done before which is backing up and then restoring an ESXi hostss configuration.  

In my examples today I am going to use the tools directly built into ESXi and vSphere to get this done.  Im going to use PowerCLI 5.5 (latest version as of this writing) to get this done.

PowerCLI is one of the many tools that are bundled for free with the vSphere environment.  I highly recommend you have it installed on your management server or workstation and if youre running vCenter on Windows its even better to place it there.  You can download PowerCLI from the VMware website.

The process of backing up and restoring the configuration is pretty simple so here we go.

Before running any of these commands you should run this command in PowerShell on Windows to make sure PowerCLI has the ability to execute the commands needed for this process to work.

Set-ExecutionPolicy RemoteSigned

Open PowerCLI and use the Connect-VIServer IPAddress command to connect to the server.

Next run the command below to backup your hosts configuration.  Make sure you create the backup location folder before you run the command.

Get-VMHostFirmware -VMHost ESXi_host_IP_Address -BackupConfiguration -DestinationPath “Output_Directory”

When the process completes youll have files that look like this:


Thats all there is to backing up the configuration of your ESXi host.  Now for the really cool part.  
If youre upgrading hosts to new hardware there a couple of things Ive done and the restore has went off without a hitch.  Make sure you have the VMware install on the new host at the exact same version as the host you backed up.  If not this isnt a supported process but you can use the "-force" command at the end of the restore to make it do it anyway.  The next thing is to ensure you have the network cables in the exact same port numbers as the old host.  In other words port 0 on the old host should get the cable for port 0 on the new.
If youre unsure which cables correspond to which port, once youve migrated all VMs off of the old host you can look at the network configuration in the vSphere client and pull the cables one at a time.  From there just label each one so you know where to put it in the new server.
Once youve got the new box cabled up, on the same build of VMware as the old server, and powered on heres all you need to do.
First put the host into maintenance mode.  This is required or the next step will not work.  You can use the hostname, IP address, or FQDN if you want.
Set-VMHost -VMHost esx1 -State “Maintenance”
Next enter the restore command.
Set-VMHostFirmware -VMHost -Restore -Force -SourcePath
Once you do this the host will immediately restart.  During the restart it will import the backed up configuration prior to completing the loading process.
After the host has fully restarted you will be able to see that all of your prior settings have been restored including those many times complicated network, VLAN, and MTU settings.
On the hosts I have performed this on if they have local storage I have had to configure the large datastore again but given how much time this saves thats a minor thing to get the new server online much, much quicker.
Good luck with your upgrades!







Get