Back Up and Restore VMware ESXi Host Configuration: A Step-By-Step Guide

Backup is one of the most important actions for continuous operation of any IT infrastructure. Running servers as virtual machines (VMs) on ESXi hosts in vSphere provides you greater advantages when backing up VM data. Host-level backup allows you to use helpful features such as agentless backup, complete VM backup (VM data + VM configuration), snapshots for making backups of running VMs, and low server load. Having healthy ESXi hosts is a key to success when running virtual machines. That’s why it is better to back up ESXi configuration. Thus, if something goes wrong with an ESXi host, its configuration can be restored in a few minutes without spending a lot of time to configure an ESXi server from scratch. Today’s blog post covers backup ESXi configuration and explores how to back up ESXi host using different methods.

Using the ESXi Command Line to Back up ESXi Host

Using the ESXi command line is the most affordable method to back up ESXi host configuration. You don’t need to install any additional software to use the ESXi command line. You have to enable ESXi shell and remote SSH access to an ESXi host. This process is explained in the blog post about ESXCLI. Once you have connected to your ESXi host via SSH, you can run the commands.

ESXi configuration is saved every hour automatically to the /bootblank/state.tgz file. For this reason, you should ensure that the current ESXi configuration is written to ESXi configuration files right now to confirm that all changes made to ESXi configuration since the last autosave are saved:

vim-cmd hostsvc/firmware/sync_config

Back up ESXi configuration:

vim-cmd hostsvc/firmware/backup_config

Backup ESXi host in ESXi command line

As a result, you’ll receive a link to download the configBundle.tgz archive from the ESXi host. You should replace the asterisk with the IP address of your ESXi host. The archive file that contains the ESXi configuration backup is saved to the /scratch/downloads directory for a short period of time (a few minutes). The scratch partition was mentioned in the blog post about installing ESXi on a USB Flash drive.

The IP address of your ESXi host can be checked in the ESXi direct console interface or using the following command:

esxcli network ip interface ipv4 get

The IP address of the ESXi host used in the current example is 192.168.101.208.

Download the ESXi backup archive as soon as possible and store it in a safe place.

How to automate backup ESXi configuration in the ESXi command line

The advantage of a command line interface is the possibility for automating tasks that it provides; Backup of ESXi configuration is no exception. Let’s review how to do this:

1. Create a directory to store backup files on your ESXi datastore.

mkdir /vmfs/volumes/datastore1/ESXi_backup

2. Create a script to back up ESXi configuration:

vi /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh

3. Add the following lines to the script:

vim-cmd hostsvc/firmware/sync_config

vim-cmd hostsvc/firmware/backup_config

find /scratch/downloads/ -name \*.tgz -exec cp {} /vmfs/volumes/datastore1/ESXi_backup/ESXi_config_backup_$(date +'%Y%m%d_%H%M%S').tgz \;

Backup ESXi host configuration – creating a simple backup script

4. Save the file and quit vi:

:wq

Note: For greater convenience, you can also include the ESXi host name or IP address to the backup file name. This will help you to avoid confusion when using multiple ESXi hosts.

5. Make the script executable:

chmod +x /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh

6. Go to the directory where the script is located:

cd /vmfs/volumes/datastore1/ESXi_backup/

7. Run the script:

./esxi_backup.sh

8. Verify that a backup file has been created:

ls -al

Backup ESXi host – a backup file is created

9. Let’s make sure the backup ESXi host script is running on schedule (automatically). Edit the scheduler configuration for this purpose:

vi /var/spool/cron/crontabs/root

10. Add the following string to perform ESXi configuration backup every day at 02:10 AM.

10 02 * * * /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh

11. Save changes in the file. In order to save changes in the read-only file, enter:

:wq!

As an alternative, you can change file permissions before editing the file:

chmod +w /var/spool/cron/crontabs/root

Backup ESXi host configuration – scheduling the backup process

After that, ESXi configuration will be backed up automatically at 02:10 AM every night to the file named ESXi_config_bakup_date_time.tgz

How to recover ESXi configuration in ESXi command line

You should have ESXi of the same version and build number installed on the machine where you want to restore the ESXi configuration. This rule is true for all ESXi configuration recovery methods considered in this blog post. If you are going to restore the ESXi configuration on the ESXi host that is installed from scratch (clearly installed), you need to set the IP address for the network interface used for ESXi management network and enable SSH access. Initial ESXi configuration is explained in this blog post. The UUID must be the same on both the ESXi server that was backed up and the ESXi server on which the configuration must be restored. Below in this section, read what to do if the UUID values are different.

Once you have prepared your freshly installed ESXi host to restore ESXi configuration from a backup, connect to the ESXi host via SSH and enter the host to the maintenance mode.

esxcli system maintenanceMode set --enable yes

or

vim-cmd hostsvc/maintenance_mode_enter

Copy the archive that contains the ESXi configuration backup to some directory on an ESXi host by using an SCP client, for example WinSCP. Let’s copy the configBundle-xxxx.tgz archive from a local machine to the /tmp/ directory on the destination ESXi server.

Copying the ESXi configuration backup archive to the destination ESXi host

Rename the configBundle-xxxx.tgz file to configBundle.tgz before you enter a command to restore ESXi configuration. Otherwise you will get an error message: “File /tmp/configBundle.tgz was not found".

You can rename the file in the ESXi shell to which you have connected via SSH:

mv /tmp/configBundle-esxi6-7b.localdomain.tgz /tmp/configBundle.tgz

Restore the ESXi configuration:

vim-cmd hostsvc/firmware/restore_config /tmp/configBundle.tgz

After running this command an ESXi host will be rebooted automatically.

How to recover ESXi configuration from a backup of ESXi configuration

After restarting the ESXi server, you should exit the maintenance mode, after which point you can use the host as usual.

esxcli system maintenanceMode set --enable no

or

vim-cmd hostsvc/maintenance_mode_exit

How to change the UUID to restore ESXi configuration

The UUID of the ESXi server can be checked in the ESXi command line interface with the command:

esxcfg-info -u

The UUID value of the backed up ESXi host is mentioned in the Manifest.txt file inside the configBundle.tgz backup archive you have made with the commands explained above.

Backup ESXi host - the ESXi UUID is stored in the Manifest.txt file inside the configBundle.tgz file

You cannot change the UUID of the ESXi server since the identifier is generated depending on the hardware. However, you can recover the ESXi configuration of the ESXi host A to the ESXi host B after changing the UUID in the Manifest.txt file stored in the configBundle.tgz ESXi configuration backup archive.

Let’s explore the algorithm that can be used to change the UUID for applying the backed up configuration on another physical server. The server A is a server which configuration is backed up and the server B is a server to which the configuration must be applied.

Stage 1

Check the UUID on the ESXi host to which you want to apply the backed up configuration (server B). This can be done with at least two methods, but the second method also allows you to check the ESXi version.

1. Run the esxcfg-info -u

2.1 Backup the configuration of the ESXi server B

vim-cmd hostsvc/firmware/sync_config

       vim-cmd hostsvc/firmware/backup_config

2.2 Copy the backup archive to the temporary directory and go to that directory

cp /scratch/downloads/_hash_value_/configBundle-localhost.localdomain.tgz /tmp

cd /tmp/

2.3 Extract files from the archive

tar zxvf configBundle.tgz

2.4 Open the Manifest.txt file with vi and check the UUID value (you will see a separate line with the UUID). Write down the UUID.

vi Manifest.txt

In our case, the UUID is 1E9E4D56-B724-DFBE-D19D-4C2D827E0188

2.5 You can delete temporary files in the /tmp/ directory:

rm configBundle-localhost.localdomain.tgz Manifest.txt state.tgz

Stage 2

1. Copy the configBundle.tgz configuration backup archive of the ESXi server A to the Server B, for example, to the /tmp/ directory and go to that directory.

2. Extract files from the configBundle.tgz archive

tar zxvf configBundle.tgz

3. Open the Manifest.txt file with vi and update the UUID value of the server A to the UUID of the server B.

vi Manifest.txt

In our case, we must change 9EA94D56-7E39-96A8-AB45-DF31EF0971EC to 1E9E4D56-B724-DFBE-D19D-4C2D827E0188.

Save the file and quit the text editor :wq

Changing the UUID value in backup files of the ESXi host

4. Rename your source configBundle.tgz file to configBundle1.tgz, for example (if the name of your ESXi configuration backup file differs from configBundle.tgz, you can skip this step).

mv configBundle.tgz configBundle1.tgz

5. Tar Manifest.txt, state.tgz and jumpstrt.gz files to a new configBundle.tgz archive:

tar zcvf configBundle.tgz Manifest.txt state.tgz jumpstrt.gz

6. Put the ESXi host into maintenance mode and restore the configuration

esxcli system maintenanceMode set --enable yes

vim-cmd hostsvc/firmware/restore_config /tmp/configBundle.tgz

How to Back up ESXi Host with vSphere CLI

Another command line interface provided by VMware to manage ESXi hosts is vSphere CLI (not to be confused with VMware PowerCLI). You should install vSphere CLI on a machine running Linux or Windows to manage ESXi hosts remotely. Perl is required to install vSphere CLI. The advantage of using vSphere CLI is its ability to use convenience and the power of bash in Linux. Ubuntu Linux is used in today’s examples.

Installing and configuring vCLI

Download vSphere CLI from VMware’s web site.

Go to the directory where the downloaded file is located and extract files from the archive.

tar -zxvf VMware-vSphere-CLI-6.5.0-4566394.x86_64.tar.gz

Install the required packages:

apt-get install -y perl-doc libmodule-build-perl libssl-dev libxml-libxml-perl libsoap-lite-perl libuuid-perl build-essential

The official VMware recommendation is to install this set of packages:

apt-get install ia32-libs build-essential gcc uuid uuid-dev perl libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl

Go to the directory where the extracted files are located and run the installer:

./vmware-install.pl

Read and accept the license agreement. If the installer asks you to install some required modules, type y and install the modules.

Installing modules for vSphere CLI to back up ESXi host configuration

Some modules must be installed manually in our case. They can be installed by using the interactive shell of Perl.

Enter the interactive shell of Perl:

perl -MCPAN -e shell

Run the command to install the required Perl module:

install Devel::StackTrace

Similarly install other modules.

Manual installation of Perl modules to back up ESXi configuration

Note: In our case, one module could not be installed in the interactive Perl shell but we can install that module with the command in the Ubuntu console:

apt-get install libcrypt-ssleay-perl

After installing Perl modules, run the VMware vSphere CLI installer again.

The installation has been completed successfully and you can see the following screen in this case:

The vSphere CLI installation has been completed successfully

Now let’s try to use vSphere CLI and enter a command in the Linux console to see a list of devices of the ESXi server (192.168.101.208 is the IP address of the ESXi server).

esxcli --server 192.168.101.208 storage core device list

Using vSphere CLI for managing an ESXi host

The server SHA-1 thumbprint is not trusted, and connection to the ESXi host has failed. This means that you should define the thumbprint for security reasons. Let’s try another command:

esxcli --server 192.168.101.208 --thumbprint B3:63:9F:67:E2:D9:C4:53:7D:A9:2A:4A:37:DC:AE:73:3C:83:C7:DA system maintenanceMode get

The username and password will be prompted in the console in the interactive mode.

A username and password are needed to run the command on an ESXi server

Try not to use commands where a username and password are typed as plain text like this:

esxcli --server 192.168.101.208 --username root --password TestPass_555 --thumbprint B3:63:9F:67:E2:D9:C4:53:7D:A9:2A:4A:37:DC:AE:73:3C:83:C7:DA system maintenanceMode get

This is due to security reasons. The executed commands are saved in Linux until you run the history -c command to clear history. If you need to avoid using the interactive mode and entering a login and password manually, you can save the ESXi session to the file and use this file when running commands. Saving sessions is secure, unlike entering a password as a plain text in the command. Saving sessions is explained below in this blog post.

Saving a thumbprint for connecting to ESXi hosts

Entering an ESXi thumbprint each time for running a command is not convenient. Fortunately, it is possible to save the thumbprint and run further commands with vSphere CLI without defining a thumbprint.

Go to the directory:

cd /usr/lib/vmware-vcli/apps/general/

You need to run the command like:

/usr/lib/vmware-vcli/apps/general/credstore_admin.pl add -s server -t thumbprint

In our particular example, the command is:

/usr/lib/vmware-vcli/apps/general/credstore_admin.pl add -s 192.168.101.208 -t B3:63:9F:67:E2:D9:C4:53:7D:A9:2A:4A:37:DC:AE:73:3C:83:C7:DA

Saving a thumbprint for running commands in vSphere CLI to back up ESXi host configuration

Now you can run commands in vSphere CLI without entering a thumbprint each time.

esxcli --server 192.168.101.208 system maintenanceMode get

Entering a login and password to execute a command on an ESXi host remotely by using vSphere CLI

However, the need of entering a login and password has not disappeared - you still must enter login/password. How can you configure vSphere CLI to run commands without entering a password each time? The answer to this question is featured in the sections below.

Using a session file for connecting to ESXi hosts

Using a saved session file is one of the methods to avoid entering a username and password when running a command on a remote ESXi host by using vSphere CLI.

First, create a directory to store ESXi configuration backup files, for example, /backup/.

mkdir /backup

Go to that directory:

cd /usr/lib/vmware-vcli/apps/session

Save your authorized ESXi host session to the file by using a Perl script with the command:

perl save_session.pl --savesessionfile /backup/192-168-101-208session --server 192.168.101.208 --username root --password TestPass_555

Where:

--savesessionfile /backup/192-168-101-208session is the name of the created session file

--server 192.168.101.208 is the name of the ESXi host whose session is saved (this ESXi host is used in multiple examples)

--username root is the name of the user who is connected to the ESXi host

--password TestPass_555 is the password for the user who is connected to the ESXi host

Now you can run commands without entering a password, but you should enter the --sessionfile key (option) and define the path to the session file. For example:

esxcli --sessionfile /backup/192-168-101-208session system maintenanceMode get

Running commands in vSPhere CLI by using a session file

Using a configuration file for connecting to ESXi hosts

The idea behind this method is to save credentials in the configuration file as a plain text and refer to this file when running ESXi commands in vSphere CLI. First, create a configuration file:

vim /backup/vcli-config

Enter credentials in the format as following:

VI_USERNAME=root

VI_PASSWORD=TestPass_555

Save the file.

Run a command on a remote ESXi server by using vSphere CLI:

esxcli --server 192.168.101.208 --config vcli-config system maintenanceMode get

Running commands in vSphere CLI by using a configuration file

As credentials are saved as plain text, this method is not secure.

Using a credential store for connecting to ESXi hosts

A credential store is the xml file located in the user directory in the vmware subdirectory ~/.vmware/credstore/vicredentials.xml. The advantage of using the credentials store to run commands on remote ESXi hosts is that a password is not saved as plain text, hence this method provides higher security.

In order to add credentials to the credential store, run the command:

/usr/lib/vmware-vcli/apps/general/credstore_admin.pl add --server 192.168.101.208 --username root

List credentials saved in the credentials store to make sure that the needed credentials are present:

/usr/lib/vmware-vcli/apps/general/credstore_admin.pl list

Run the command on the remote ESXi host without entering a password by using the credentials store.

# esxcli --server 192.168.101.208 --credstore /root/.vmware/credstore/vicredentials.xml system maintenanceMode get

If you use a non-root user, the credentials file is saved in /home/user_name/.vmware/credstore/vicredentials.xml

Running commands in vSphere CLI without entering credentials that are saved in the credentials store

On the screenshot below, you can see how credentials are saved in the credentials store file.

ESXi credentials are saved in the credentials store

Using vSphere CLI to back up ESXi host configuration

Now that you have configured vSphere CLI on the Ubuntu Linux machine, you can run the commands and back up ESXi configuration.

Go to the /usr/bin/ directory

cd /usr/bin

Now you can make a backup of ESXi configuration without entering a username and password after saving credentials in the credentials store:

vicfg-cfgbackup --server 192.168.101.208 --credstore /root/.vmware/credstore/vicredentials.xml -s /backup/192-168-101-208-esxi-cfg.tgz

Or after saving a session in the session file:

vicfg-cfgbackup --sessionfile /backup/192-168-101-208session -s /backup/192-168-101-208-esxi-cfg.tgz

Backup ESXi host configuration in vSphere CLI by using a session file for authentication

Note: vicfg- commands are deprecated. It’s better to use ESXCLI equivalent commands in the command line interface when working with ESXi hosts.

Note: The disadvantage of using the --sessionfile option is the timeout of 30 minutes when idle after running the last command in vSphere CLI. After that, you have to authenticate and create a session file again.

If you want to create a backup of ESXi configuration while entering a password in the interactive mode, you can run the command:

vicfg-cfgbackup --server 192.168.101.208  -s /backup/192-168-101-208-esxi-cfg.tgz

Backup ESXi host configuration and entering a login and password in the interactive mode

How to make backup ESXi configuration automated

If you have a dynamically changed environment and the configuration of ESXi hosts often changes, manual backup of ESXi hosts may not be rational. In this case, you can automate your backup ESXi configuration by adding a backup command or a backup script that contains multiple commands to the scheduler.

Crontab is a scheduler in Linux. Edit the scheduler configuration in Linux to run the ESXi configuration backup command periodically and automatically.

crontab -e

Note: If you are editing the crontab configuration for the first time, you should select the default text editor which must be used to edit the crontab configuration. In our example, we use /usr/bin/vim.basic for this purpose.

The format of crontab configuration is the following:

minutes hours day_of_the_month month day_of_the_week command

Let’s back up ESXi host configuration every night at 03:25 AM:

25 03 * * * /usr/bin/vicfg-cfgbackup --server 192.168.101.208 --config /backup/vcli-config -s /backup/192-168-101-208-esxi-cfg-cron.tgz

Write the configuration of the crontab scheduler and quit the text editor vim.

:wq

Making backup ESXi host configuration automated by using crontab

Let’s wait for 03:25 AM to check the directory to which ESXi backup configuration files must be saved.

ls -al

As you see on the screenshot below, the backup file of ESXi host configuration was created at 03:25 automatically.

Backup ESXi host configuration is saved automatically

Now ESXi configuration backup has been made automatically, which is great, but there is a disadvantage. Each time when crontab runs a scheduled command to make the ESXi configuration backup, the previous tgz file is overwritten by the new tgz file. This situation can cause issues for you if the backup with the correct ESXi configuration made yesterday gets overwritten by a file created today that contains the incorrect ESXi configuration. The right way to prevent such an issue is backing up ESXi configuration to different files.

Let’s create a simple script to save ESXi configuration each time as a separate file with a unique file name that contains the date and time of the ESXi configuration backup file creation in the name of the file. Creating a script allows you to add commands to back up multiple ESXi hosts by running a single script.

1. Create the esxi_backup.sh file in the /backup/ directory:

vim /backup/esxi_backup.sh

2. Add lines to the file as following:

#!/bin/bash

ESXI101_208_BACKUP_NAME="192-168-101-208-$(date +'%Y%m%d_%H%M%S')esxi-cfg.tgz"

vicfg-cfgbackup --server 192.168.101.208 --config /backup/vcli-config -s /backup/$ESXI101_208_BACKUP_NAME

3. Write changes to the file and quit the text editor vim.

:wq

4. Make the file executable:

chmod +x /backup/esxi_backup.sh

5. Edit the scheduler configuration:

crontab -e

6. Add the line like this:

50 06 * * * /backup/esxi_backup.sh

Let’s set crontab to run the ESXi configuration backup script at 06:50 AM. Disable the previous scheduled task you have added before by adding the # character in the beginning of the line.

The automatic backup ESXi host configuration that creates files with unique names

7. Wait for the set time and then check to see whether the ESXi configuration backup archive has been created.

ESXi configuration backup files have unique names

This is a simple script that demonstrates the idea of automation. You can create complex scripts to back up multiple ESXi hosts.

Note: After each ESXi reboot or 30-minutes of idle time, the ESXi session becomes not authenticated. Keep in mind this feature when creating a script for automated ESXi backup.

How to recover ESXi configuration in vSphere CLI

The requirements for restoring ESXi configuration by using vSphere CLI are similar to requirements in place for other methods. In order to restore ESXi configuration, make sure that remote access via SSH is enabled and the IP address of the ESXi server is known (it is recommended to use the same IP address as the IP address of the backed up ESXi host) and then run the command like:

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

In our particular example, the command is:

vicfg-cfgbackup --server=192.168.101.208 --username=root -l /backup/192-168-101-208-esxi-cfg.tgz

If the UUID of the target ESXi host on which you want to restore the configuration has a UUID that is different from the UUID of the backed up ESXi server (whose UUID is defined in the Manifest.txt file inside the tgz backup archive), you can use the -f key (force) to override the UUID.

Recovering ESXi host configuration from a backup

You can check the UUID of the running ESXi host with the command, as you recall:

esxcfg-info -u

Using Power CLI to Back up ESXi Host

Users who like Windows can use PowerCLI, which is a set of PowerShell cmdlets to back up ESXi configuration. Some basic PowerCLI commands are explained in this blog post. First you have to install PowerCLI on your operating system. The algorithm is the following:

1. Run PowerCLI as administrator in Windows.

2. Connect to your ESXi server:

Connect-VIServer ESXi_IP_address -user user_name -password your_password

In our case, we use the commands:

Connect-VIServer 192.168.101.208 -user root -password TestPass_555

Get-VMHostFirmware -vmhost 192.168.101.208 -BackupConfiguration -DestinationPath "C:\backup ESXi host"

Backup ESXi host with PowerCLI

If your ESXi hosts are managed by vCenter Server, you can connect to vCenter first and then back up ESXi configuration on your hosts in PowerCLI without needing to authenticate each time before backing up each host configuration.

Connect-VIServer 10.10.10.16

Enter your administrative login and password for accessing vCenter Server. A popup window appears for this purpose.

Backup ESXi host with PowerCLI after connecting to the vCenter server

Back up ESXi configuration of each host:

Get-VMHostFirmware -vmhost 10.10.10.61 -BackupConfiguration -DestinationPath "C:\backup ESXi host"

Get-VMHostFirmware -vmhost 10.10.10.46 -BackupConfiguration -DestinationPath "C:\backup ESXi host"

Backup ESXi configuration of each host in PowerCLI

How to restore ESXi configuration in PowerCLI

Run VMware PowerCLI as an administrator. Connect to an ESXi host on which you want to recover configuration (in our example we will recover configuration on the ESXi host whose IP address is 192.168.101.208). Then enter the host into maintenance mode:

Set-VMHost -VMHost 192.168.101.208 -State Maintenance

Make sure that VMs residing on that ESXi host are powered off or migrated to another ESXi host before recovering the ESXi configuration. Be aware that after executing a command for restoring configuration, the ESXi host will reboot automatically. Restore configuration with the Set-VMHostFirmware restore command:

Set-VMHostFirmware -vmhost 192.168.101.208 -Restore -SourcePath "C:\backup ESXi host\configBundle-192.168.101.20

8.tgz" -HostUser root -HostPassword TestPass_555

ESXi configuration is recovered in PowerCLI

The version, build number and UUID of an ESXi host on which the configuration is recovered must match the version, build number and UUID of an ESXi host whose backup you are using to restore configuration. Use the -force key in the command to skip the UUID check.

Manual Backup and Restore of ESXi Configuration

You should also be ready for a situation in which you are unable to log in to your ESXi host, or when an ESXi host cannot boot and you cannot use the command line interface to run the command for backing up or restoring ESXi configuration. This may happen on account of hardware failure or software issues. In this case, it is better to know how to back up and recover ESXi configuration manually.

Note: As you recall from the default crontab configuration on an ESXi host, the /sbin/auto-backup.sh script is run every hour and when an ESXi host is rebooted or shut down. This script is intended to back up (save) ESXi configuration stored in memory to the /bootbank/state.tgz file.

The ESXi configuration is stored in the computer’s RAM when an ESXi server is running (the appropriate RAM disk is mounted on /etc/ directory). When ESXi is booting, system files are extracted from the /bootbank/state.tgz archive to the /etc/ directory. You can manually copy the /bootbank/state.tgz file if your ESXi host is running by using an SCP client such as WinSCP (remote SSH access must be enabled). As an alternative, you can boot from the Live DVD and copy the state.tgz file manually if your ESXi host is not bootable (for example, due to hardware failure).

Manual recovery workflow

1. Prepare the backup archive you made previously with ESXi shell, vSphere CLI or PowerCLI. The name of said file is configBundle-192-168-101-208.tgz in our case. You can copy the file to a USB flash drive, for example, and insert that flash drive into a USB port of the ESXi server on which you have to recover system configuration.

2. Boot from the live CD/DVD on the machine where ESXi is installed. You can use the Ubuntu installation disk as a live CD/DVD.

3. Open the console (terminal) in Linux

4. List the partitions:

ls -al /dev/sd*

fdisk -l | grep /dev/sda

In this case, we need the /dev/sda5/ partition that is marked as Microsoft basic data.

ESXi disk partitions were mentioned in the blog post about Booting ESXi from a USB flash drive and ESXi password recovery.

Mounting the partition that contains the ESXi configuration archive

We are interested in the /dev/sda5 partition in this case.

5. Create the directory to which the /dev/sda5 partition will be mounted:

mkdir /mnt/sda5

6. Mount the disk partition to that directory:

mount /dev/sda5 /mnt/sda5

7. In the /mnt/sda5 directory, you can find the state.tgz file that contains ESXi configuration. This directory (in which state.tgz is stored) is called /bootblank/ when an ESXi host is booted.

8. Copy the ESXi configuration backup archive from a USB flash drive to the /tmp/directory of Ubuntu loaded from a Live DVD. In our example, we copy:

cp /media/Ubuntu/Ubuntu\ 18.0/backup_ESXi_host/configBundle-192-168-101-208.tgz /tmp/configBundle.tgz

9. Extract files from the backup archive:

tar zxvf /tmp/configBundle.tgz

10. You can see that the state.tgz file is extracted from the archive.

ls -al /tmp/

11. Rename the original state.tgz file that is located on the /dev/sda5 partition mounted on /mnt/sda5/

mv /mnt/sda5/state.tgz /mnt/sda5/state-old.tgz

12. Copy the state.tgz file you have extracted from the ESXi configuration backup archive (configBundle.tgz) to the /tmp/ directory

cp /tmp/state.tgz /mnt/sda5/

13. Unmount mounted partitions

umount /dev/sda5/

14. Reboot the server. Eject the Ubuntu Live DVD and boot from the disk on which ESXi is installed.

init 6

15. Now your ESXi configuration should be restored.

Conclusion

Today’s blog post has covered four methods to back up and restore ESXi configuration. Using the ESXi command line interface is good because you don’t need to install additional software; the advantages of vSphere CLI are the ability to run commands remotely by using Linux machines and the ability to make the backup ESXi configuration automated; PowerCLI may be appreciated by Windows users. If your ESXi host is not healthy and you cannot boot the host, there is the possibility of backing up and restoring the configuration manually. Be aware that bootblank information and information about VMs is not stored in the ESXi configuration backup file. After restoring the ESXi configuration, you may need to register virtual machines in your inventory.

Now you know how to back up ESXi host, but don’t forget to back up your virtual machines. NAKIVO Backup & Replication is a universal backup solution that can back up your VMware VMs, Hyper-V VMs, Amazon EC2 instances as well as physical Linux and Windows servers. Download the full-featured free trial to see how reliable backup can be in your environment.

Back Up and Restore VMware ESXi Host Configuration: A Step-By-Step Guide
Rate this post

Share: