How To Back Up and Restore Esxi Host
How To Back Up and Restore Esxi Host
How To Back Up and Restore Esxi Host
Aleks (NAKIVO)
Dec 23, 2020 5 Minute Read
Spice(17)
Reply (0)
Subscribe
Share
While the importance of backing up VMware vSphere VMs has been discussed at length,
little attention has been paid to ESXi host configuration backup. A failure to backup the ESXi
host configuration can trigger a number of consequences, ranging from minor to grave.
Even if you manage to mitigate the effects of ESXi host breakdown, reconfiguring it is neither
the most enjoyable nor the most practical use of your time. For this reason, you are advised to
keep your ESXi host configuration safe and recoverable at all times. Ahead is a guide that will
help you achieve that goal.
The guide covers backup and restoration of VMware ESXi hosts using 4 methods: ESXi
command line, vSphere CLI, PowerCLI, and manually.
57 Steps total
Step 1: Method 1: Using ESXi Command Line to Back Up
ESXi Hosts
The use of the ESXi command line to backup up ESXi hosts does not require the installation
of additional software. To run the commands, enable ESXi Shell and connect to a target ESXi
host via SSH.
vim-cmd hostsvc/firmware/sync_config
vim-cmd hostsvc/firmware/backup_config
The command will produce a link for downloading the configBundle.tgz archive.
Note that you have to replace the asterisk in the provided link with your IP/FQDN.
Alternatively, access the backup file in the /scratch/downloads directory, where it is stored as
configBundle-HostFQDN.tgz.
mkdir /vmfs/volumes/datastore1/ESXi_backup
vi /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh
Expand
chmod +x /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh
cd /vmfs/volumes/datastore1/ESXi_backup/
./esxi_backup.sh
Expand
ls -al
vi /var/spool/cron/crontabs/root
Step 13: To perform a daily backup of ESXi configuration
at 3:15 AM
To perform a daily backup of ESXi configuration at 3:15 AM:
15 03 * * * /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh
Expand
:wq!
chmod +w /var/spool/cron/crontabs/roo
Then, connect to the target ESXi host via SSH and put the host into maintenance mode:
or
vim-cmd hostsvc/maintenance_mode_enter
Expand
Use an SCP client to copy the archive with the ESXi configuration (configBundle-xxxx.tgz)
to the target ESXi host directory.
mv /tmp/configBundle-esxi6-7b.localdomain.tgz /tmp/configBundle.tgz
Expand
or
vim-cmd hostsvc/maintenance_mode_exit
and
apt-get install ia32-libs build-essential gcc uuid uuid-dev perl libssl-dev perl-doc liburi-perl
libxml-libxml-perl libcrypt-ssleay-perl
Step 23: Run the installer from the directory where the
downloaded file is unpacked
Run the installer from the directory where the downloaded file is unpacked:
./vmware-install.pl
When prompted to accept the license agreement, type yes and press Enter. If prompted to
install additional modules, type yes and press Enter.
install Devel::StackTrace
cd /usr/lib/vmware-vcli/apps/general/
Step 27: Save a thumbprint
Expand
Save a thumbprint:
/usr/lib/vmware-vcli/apps/general/credstore_admin.pl list
Expand
Place the host into maintenance mode without entering login credentials:
/home/user_name/.vmware/credstore/vicredentials.xml
Expand
vim /backup/esxi_backup.sh
!/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
:wq
chmod +x /backup/esxi_backup.sh
crontab -e
Note: if you are editing a crontab file for the first time, select the default text editor, e.g. vim.
Expand
50 06 * * * /backup/esxi_backup.sh
Step 38: List directory contents
Expand
List directory contents to check whether ESXi configuration was backed up at 6:50 AM:
ls –al
Note that the ESXi session timeouts automatically after a reboot and every 30 minutes.
Expand
Enable remote access via SSH and ensure that the ESXi server’s IP address is known. Then,
run a command of the following format:
For example:
Expand
Run PowerCLI as an administrator and connect to the target ESXi server with a command of
the following format:
For example:
Connect-VIServer 10.10.10.16
Important: Before restoring the ESXi configuration, migrate or power off VMs on the target
ESXi host.
Note that the UUID of the target ESXi host should match the UUID of the backed up ESXi
host. Use the –force key to skip the UUID check.
Step 46: Copy the backup archive to a USB flash drive and
connect it to the target ESXi host
Copy the backup archive, previously created with ESXi shell, vSphere CLI or PowerCLI, to a
USB flash drive and connect it to the target ESXi host.
Expand
mkdir /mnt/sda5
ls -al /tmp/
mv /mnt/sda5/state.tgz /mnt/sda5/state-old.tgz
Step 55: Copy the state.tgz file extracted from the backup
archive to the /tmp/directory
Copy the state.tgz file extracted from the backup archive to the /tmp/directory:
cp /tmp/state.tgz /mnt/sda5/
umount /dev/sda5/
init 6
To attain and maintain a smooth operational workflow and access to mission-critical data, use
a reliable backup solution – NAKIVO Backup & Replication:
https://www.nakivo.com/vmware-backup
The seamless integration with VMware vSphere allows NAKIVO Backup & Replication to
back up and recover VMs, applications and data within minutes:
https://www.nakivo.com/resources/download/trial-download