PowerCLI Basics – Backup and Restore ESXi Configuration Data

Here is a quick post on how to backup and restore the ESXi configuration data using PowerCLI.

Cmdlets used and the corresponding reference page:

Backup

  1. First, connect to the vCenter Server with the PowerCLI C:\> Connect-VIServer command and enter your credentials.
  2. Backup the configuration data with PowerCLI C:\> Get-VMHostFirmware -VMHost <IP_or_FQDN> -BackupConfiguration -DestinationPath <Path>

For example:

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.

Restore

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.

  1. Connect to the vCenter Server with the PowerCLI C:\> Connect-VIServer command and enter your credentials.
  2. 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.
  3. Restore the configuration data from the backup bundle by running the PowerCLI C:\> Set-VMHostFirmware -VMHost <IP_or_FQDN> -Restore -Force -SourcePath <Path> command.
  4. The host will reboot immediately after you hit the enter key.

For example:

PowerCLI C:\> Set-VMHostFirmware -VMHost 10.10.10.21 -Restore -Force -SourcePath c:\esx03.dr-lab-c.local.tgz

Cheers!

– Marek.Z

2 Comments

Leave a reply...