Skip to main content
Goline It Services Logo

News

  • GOLINE SA is excited to announce a new partnership with NetApp, a global leader in cloud data services and storage solutions. This collaboration aims to help organizations modernize their IT infrastructure, streamline data management, and enhance performance across cloud and hybrid environments. Modern Data Solutions for Businesses Through this partnership, GOLINE integrates advanced data management solutions, enabling businesses to securely store, manage, and access critical information across cloud, on-premises, or hybrid setups. Clients can benefit from: Flexible and scalable storage solutions to meet growing data needs Simplified management of cloud and on-premises environments Enterprise-grade security for sensitive and mission-critical data...
  • GOLINE SA is proud to announce a new strategic partnership with Omnissa, a global leader in digital workspace platforms and Horizon Cloud Service solutions. This collaboration marks a significant step forward in helping organizations embrace secure, flexible, and high-performance work environments. Why Choose Omnissa for Your Business? The platform enables virtual desktops, applications, and unified endpoint management. Organizations can deploy scalable workspaces across cloud, hybrid, or on-premises setups. Key benefits include: Easy access to desktops and apps on any device Centralized management for Windows, macOS, iOS, Android, and ChromeOS Strong security with access controls and multi-factor authentication Automated scaling to...
  • Goline is proud to announce a strategic partnership with Cloudflare, the world leader in web performance and security solutions. This collaboration aims to provide goline.ch customers with state-of-the-art protection against cyber threats while delivering lightning-fast website performance. Through this partnership, Goline integrates Cloudflare’s advanced services, including DDoS protection, CDN caching, DNS security, and edge computing, allowing businesses to secure and optimize their websites effortlessly. Users will benefit from improved page load speed, enhanced reliability, and robust defense against malicious attacks. This partnership with Cloudflare enables goline to offer unmatched security and performance solutions to clients. By leveraging Cloudflare’s cutting-edge technology,...

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:
  • Backing Up Configuration Information with vicfg-cfgbackup section in the vSphere 5.1 Command Line Documentation
  • Get-VMHostFirmware section in the vSphere PowerCLI Reference
  • Set-VMHostFirmware section in the vSphere PowerCLI Reference
11 / 100 SEO Score
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x