Backing up and restoring ESXi configuration using the vSphere | GOLINE
Goline Logo

FAQ

News

  • In the supply and logistics sectors, email communication is pivotal. However, organizations face threats like email fraud and phishing. GOLINE SA's clients struggled with configuring email authentication protocols manually. To address this challenge, GOLINE SA became an MSP Partner of PowerDMARC, collaborating to streamline implementation and management. PowerDMARC's cloud-based platform automated DMARC, SPF, and DKIM protocols for GOLINE SA's clients. This streamlined the transition to DMARC enforcement policies, bolstering domain protection without compromising email deliverability. The intuitive platform facilitated easy navigation and provided detailed reporting for proactive issue resolution. GOLINE SA's clients experienced tangible benefits: Enhanced Email Security: Automated protocols...
  • Route RPKI validation April 1st, 2022
    RPKI is a security framework by which network owners can validate and secure the critical route updates or Border Gateway Protocol (BGP) announcements between public Internet networks. BGP is essentially the central nervous system of the Internet and one of its fundamental building blocks. The main function of BGP is to facilitate efficient routing between Autonomous Systems (AS), by building and maintaining the Internet routing table. The Internet routing table is effectively the navigation system of the Internet and without it, traffic would be unable to flow between its constituent networks. Unfortunately, routing equipment alone cannot distinguish between legitimate and malicious routing announcements,...
  • RIPE – Atlas Anchor February 17th, 2022
    We have become an even more integral part of the RIPE Atlas project by hosting an anchor, a device that allows for latency analysis of traffic between autonomous systems.https://atlas.ripe.net/probes/7073/RIPE Atlas anchors play an integral role in the RIPE Atlas network by acting both as enhanced RIPE Atlas probes with more measurement capacity, as well as regional measurement targets within the greater RIPE Atlas network. Anchors are able to perform many more measurements than a regular RIPE Atlas probe, and the large amount of data they collect is made available to everyone. In addition, anchors act as powerful targets that can...

Backing up and restoring ESXi configuration using the vSphere

Paolo Caparrelli VMware 22 June 2022

Backing up and restoring ESXi configuration using the vSphere Command-Line Interface and vSphere PowerCLI (2042141)

Purpose

This article provides steps to backup and restore the configuration of an ESXi host using the vSphere Command-Line Interface (vSphere CLI) and vSphere PowerCLI.

Resolution

Backing up ESXi host configuration data


Using the vSphere CLI

To back up the configuration data for an ESXi host using the vSphere CLI, run this command:

vicfg-cfgbackup –server=ESXi_host_IP_address –username=root -s
output_file_name


If you are using vSphere CLI for Windows, run this command:
 

vicfg-cfgbackup.pl –server=ESXi_host_IP_address –username=root -s output_file_name

Where ESXi_host_IP_address is the IP address of the ESXi host and output_file_name is the name of the backup file you create.

Note: From vSphere CLI for Windows, ensure you are executing the command from C:Program FilesVMwareVMware vSphere CLIbin

For example:
vSphere CLI:

vicfg-cfgbackup –server=10.0.0.1 –username=root -s ESXi_test1_backup.tgz

vSphere CLI for Windows:

vicfg-cfgbackup.pl –server=10.0.0.1 –username=root -s ESXi_test1_backup.tgz

Note: Use the –password=root_password option (where root_password is the root password for the host) to avoid being prompted for the root user password when you run the script.

A backup text file is saved in the current working directory where you run the vicfg-cfgbackup script. You can also specify a full output path for the file.


Using the vSphere PowerCLI

To back up the configuration data for an ESXi host using the vSphere PowerCLI, run this command:
 
Get-VMHostFirmware -VMHost ESXi_host_IP_address -BackupConfiguration -DestinationPath output_directory

Where ESXi_host_IP_address is the IP address of the ESXi host and output_directory is the name of the directory where the output file will be created.

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.
 

Using the ESXi Command Line


To synchronize the configuration changed with persistent storage, run this command:

vim-cmd hostsvc/firmware/sync_config

To backup the configuration data for an ESXi host, run this command:
 
vim-cmd hostsvc/firmware/backup_config

Note: The command should output a URL in which a web browser may be used to download the file. The backup file is located in the /scratch/downloads directory as configBundle-<HostFQDN>.tgz

Restoring ESXi host configuration data


Using the vSphere CLI

Note: When restoring configuration data, the build number of the host must match the build number of the host that created the backup file. Use the -f option (force) to override this requirement.

To restore the configuration data for an ESXi host using the vSphere CLI:
  1. Power off all virtual machines that are running on the host that you want to restore.
  2. Log in to a server where the vCLI is installed.
  3. Run the vicfg-cfgbackup script with the -l flag to load the host configuration from the specified backup file:

    vSphere CLI:

    vicfg-cfgbackup –server=ESXi_host_IP_address –username=root -l backup_file

    vSphere CLI for Windows:

    vicfg-cfgbackup.pl –server=ESXi_host_IP_address –username=root -l backup_file

    Where ESXi_host_IP_address is the IP address of the ESXi host and backup_file is the name of the backup file to use for the restore.

    For example:

    vicfg-cfgbackup –server=10.0.0.1 –username=root -l ESXi_test1_backup.txt

    vSphere CLI for Windows:

    vicfg-cfgbackup.pl –server=10.0.0.1 –username=root -l ESXi_test1_backup.txt

    Notes:
    • When you run this command, you are prompted for confirmation before proceeding. You can override this safety feature using the -q option.
    • Use the –password=root_password option (where root_password is the root password for the host) to avoid being prompted for the root user password when you run the script.

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

Using the vSphere PowerCLI

Note: When restoring configuration data, the build number of the host must match the build number of the host that created the backup file. Use the -force option to override this requirement.

  1. Put the host into maintenance mode by running the command:

    Set-VMHost -VMHost ESXi_host_IP_address -State 'Maintenance'

    Where ESXi_host_IP_address is the IP address of the ESXi host.


  2. Restore the configuration from the backup bundle by running the command:

    Set-VMHostFirmware -VMHost ESXi_host_IP_address -Restore -SourcePath backup_file -HostUser username -HostPassword password


    Where ESXi_host_IP_address is the IP address of the ESXi host, backup_file is the name of the backup bundle to use for the restore, and username and password are the credentials to use when authenticating with the host.

    For example:

    Set-VMHostFirmware -VMHost 10.0.0.1 -Restore -SourcePath c:bundleToRestore.tgz -HostUser root -HostPassword exampleRootPassword
Using the ESXi Command Line:

Note: When restoring configuration data, the build number of the host must match the build number of the host that created the backup file.

  1. Put the host into maintenance mode by running the command:

    vim-cmd hostsvc/maintenance_mode_enter
  2. Copy the backup configuration file to a location accessible by the host and run the command:

    In this case, the configuration file was copied to the host's /tmp directory. For more information, see Using SCP to copy files to or from an ESX host (1918).
vim-cmd hostsvc/firmware/restore_config /tmp/configBundle.tgz
 
Note: Executing this command will initiate an automatic reboot of the host after command completion.

Additional Information

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:

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x