Here is a quick post on how to backup and restore the ESXi configuration data using PowerCLI.
Cmdlets used and the corresponding reference page:
- First, connect to the vCenter Server with the PowerCLI C:\> Connect-VIServer command and enter your credentials.
- Backup the configuration data with PowerCLI C:\> Get-VMHostFirmware -VMHost <IP_or_FQDN> -BackupConfiguration -DestinationPath <Path>
PowerCLI C:\> Get-VMHostFirmware -VMHost 10.10.10.21 -BackupConfiguration -DestinationPath D:\Configs\esx03
The backup file will be saved as a .tgz file in the folder specified by the DestinationPath option.
When restoring configuration data, the build number of the host should match the build number of the host that created the backup file but you can use the -Force option to override this requirement.
- Connect to the vCenter Server with the PowerCLI C:\> Connect-VIServer command and enter your credentials.
- If the host is not in maintenance mode you can put it in maintenance mode by running PowerCLI C:\> Set-VMHost -VMHost <IP_or_FQDN> -State ‘Maintenance’ command. Otherwise proceed to the next step.
- Restore the configuration data from the backup bundle by running the PowerCLI C:\> Set-VMHostFirmware -VMHost <IP_or_FQDN> -Restore -Force -SourcePath <Path> command.
- The host will reboot immediately after you hit the enter key.
PowerCLI C:\> Set-VMHostFirmware -VMHost 10.10.10.21 -Restore -Force -SourcePath c:\esx03.dr-lab-c.local.tgz