There are two conditions which need to be satisfied:
You can backup and restore the host configuration using one of these methods:
# vim-cmd hostsvc/firmware/sync_config
# vim-cmd hostsvc/firmware/backup_config
Put the host into maintenance mode by running the below command:
# vim-cmd hostsvc/maintenance_mode_enter
Run this command to backup the ESXi configuration:
# vicfg-cfgbackup --server=ESXi_host_IP_address --username=root -s output_file_name
In vSphere CLI for Windows:
For example:
Notes:
Restoring the host configuration restores the state of the ESXi along with any vSphere standard switch networking configuration.
Note: When restoring configuration data, the build number of the host must match the build number of the host on backup file and UUID (can be obtained using the command "esxcfg-info -u") of the host should match the UUID of the host on backup file. Use the -f option (force) to override the UUID mismatch. However, starting from vSphere 7.0 U2, the configuration could be encrypted using TPMs and in which case, the -force option will not work if the host got changed. We need the same TPM that was used on the host during backup, to restore. In other words,
from vSphere 7.0U2, the override will not work if the host has TPM enabled.
To restore the configuration data for an ESXi host using the vSphere CLI:
vSphere CLI
# vicfg-cfgbackup --server=ESXi_host_IP_address --username=root -l backup_file
For example:
# vicfg-cfgbackup --server=10.0.0.1 --username=root -l ESXi_test1_backup.txt
vSphere CLI for Windows:
# vicfg-cfgbackup.pl --server=ESXi_host_IP_address --username=root -l backup_file
For example:
# vicfg-cfgbackup.pl --server=10.0.0.1 --username=root -l ESXi_test1_backup.txt
Note: Bypass the confirmation to proceed with the -q option.
To restore an ESXi host to the stock configuration settings, run the command:
# vicfg-cfgbackup --server=ESXi_host_IP_address --username=root -r
For example:
# vicfg-cfgbackup --server=10.0.0.1 --username=root -r
Note: ESXi host should be rebooted for the configuration changes to take effect.
# Get-VMHostFirmware -VMHost ESXi_host_IP_address -BackupConfiguration -DestinationPath output_directory
For ESXi 6.7, see Reset the System Configuration
For example:
# Get-VMHostFirmware -VMHost 10.0.0.1 -BackupConfiguration -DestinationPath C:\Downloads
Note: A backup file is saved in the directory specified with the -DestinationPath option.
Note: When restoring configuration data, the build number of the host must match the build number of the host on backup file and UUID (can be obtained using the command esxcfg-info -u) of the host should match the UUID of the host on backup file. Use the -force option to override the UUID mismatch. However, starting from vSphere 7.0 U2, the configuration could be encrypted using TPMs and in which case, the -force option will not work if the host got changed. We need the same TPM that was used on the host during backup, to restore. In other words,
from vSphere 7.0U2, the override will not work if the host has TPM enabled.
# Set-VMHost -VMHost ESXi_host_IP_address -State 'Maintenance'
# Restart-VMHost -VMHost ESXi_host_IP_address -Confirm:$false
# Set-VMHostFirmware -VMHost ESXi_host_IP_address -Restore -SourcePath backup_file -HostUser username -HostPassword password
# Set-VMHostFirmware -VMHost 10.0.0.1 -Restore -SourcePath c:\bundleToRestore.tgz -HostUser root -HostPassword exampleRootPassword
Note: The information about virtual machines is not stored in the config backup and the virtual machines must be re-inventoried from the datastore browser after a config backup restore. Also, bootbank information is not stored in a config backup. If needed, this must be backed up and downloaded separately in a compressed tar file.
For more information, see:
Note: if you have installed a version of vSphere later than 5.1, see the Command Line Document and PowerCLI Reference for that version in the VMware Documentation Library.
PowerCLI Notes:
To be alerted when this document is updated, click the Subscribe to Article link in the Actions box.
ESXi ホストの構成のバックアップ方法
如何备份 ESXi 主机配置
Note:
Back-up and restore of the ESX host configuration is not supported for Distributed Services Engine server configurations - ESX host with DPUs.
Host configuration backup and restore is not applicable to hosts provisioned with Autodeploy. Please refer Installing ESXi Using vSphere Auto Deploy for more information.