Aik Designs

20 Years Of Creative Solutions

How To Backup VmwareESXi: 4 Easy Methods Step By Step

How To Backup VmwareESXi

How To Backup VmwareESXi is the question every VMware admin asks after the first bad update or failed disk. A backup of the ESXi host configuration lets you rebuild a host in minutes instead of reconfiguring networking, storage, users and licensing from scratch. This guide walks through four working methods: the ESXi shell, vSphere CLI, PowerCLI and manual recovery. Each one includes the restore steps, so you are covered when something goes wrong.

A virtual machine is a simulated computer that runs on top of a host. If you want a safe place to practise these steps first, a decent lab machine helps; see this list of best laptops for virtualization.

⏱️
10–20 Min
Per host
🧰
4 Methods
Shell, vCLI, PowerCLI, manual
💾
1 File
configBundle .tgz
⚠️
Same Build
Needed to restore

Who, What, When, Where, Why And How

Question Answer
Who needs this? Anyone who runs one or more ESXi hosts: sysadmins, home lab users and small business IT teams.
What is backed up? The host configuration: network settings, virtual switches, storage settings, users, licence and advanced options. Not the VMs.
When should you back up? Before upgrades or patches, after any major config change, and on a daily or weekly schedule.
Where is the backup stored? The host creates a configBundle .tgz file. Store it on a datastore, a file server and one offline copy.
Why bother? A restore takes minutes. Rebuilding by hand takes hours and invites mistakes.
How is it done? With the ESXi shell, vSphere CLI, PowerCLI, or a manual copy of the boot bank state file.

Before You Start

  • Enable SSH and the ESXi shell on the host (Host > Manage > Services in the ESXi Host Client), or use the DCUI.
  • Note the host IP address. The examples below use 192.168.101.208; replace it with yours.
  • Write down the exact ESXi version and build number. You need the same build to restore.
  • Have a safe location ready for the backup file, such as a datastore folder and a network share.
🛑 Caution: Every example below is a template. Test it on a lab host first, and never paste real passwords into scripts you share.

Method 1: Back Up ESXi Host Using The ESXi Shell

This is the cheapest method. You do not need to install anything. ESXi already saves its running configuration to the boot bank roughly every hour, but before you take a backup you should force a fresh save so the file contains your latest changes.

Step 1: Sync And Back Up The Configuration

Connect to the host over SSH as root and run:

vim-cmd hostsvc/firmware/sync_config
vim-cmd hostsvc/firmware/backup_config

The second command prints a URL ending in configBundle-hostname.tgz. The asterisk in that URL stands for the host, so replace it with the IP address, for example http://192.168.101.208/downloads/.... Open that URL in a browser, or copy the file from /scratch/downloads with SCP. The file stays there for only a short time.

Step 2: Store It Safely

Download the archive and keep it somewhere other than the host itself. Add the date and hostname to the file name so you can tell versions apart.

Restore The Configuration In The ESXi Shell

  1. Copy the backup file to the host as /tmp/configBundle.tgz (WinSCP or scp).
  2. Put the host in maintenance mode: vim-cmd hostsvc/maintenance_mode_enter
  3. Run the restore: vim-cmd hostsvc/firmware/restore_config /tmp/configBundle.tgz
  4. The host reboots by itself. When it comes back, exit maintenance mode and check your settings.
⚠️ Warning: The ESXi version, build number and host UUID must match the backup. If you are rebuilding a failed host, install the same ESXi build first, then restore.

Automate The ESXi Shell Backup

Scripts are where the command line shines. The steps below create a script that backs up the configuration and copies it to a datastore with a time stamp.

Step 1: Create A Folder And A Script

mkdir -p /vmfs/volumes/datastore1/ESXi_backup
vi /vmfs/volumes/datastore1/ESXi_backup/esxi-backup.sh

Add these lines. Change the datastore name to match your environment:

#!/bin/sh
vim-cmd hostsvc/firmware/sync_config
vim-cmd hostsvc/firmware/backup_config
sleep 5
find /scratch/downloads/ -name "*.tgz" -exec cp {} /vmfs/volumes/datastore1/ESXi_backup/ESXi_config_backup_$(date +%Y%m%d_%H%M%S).tgz \;

Step 2: Make It Executable And Test It

chmod +x /vmfs/volumes/datastore1/ESXi_backup/esxi-backup.sh
/vmfs/volumes/datastore1/ESXi_backup/esxi-backup.sh
ls -l /vmfs/volumes/datastore1/ESXi_backup/

Check that a new .tgz file appears in the folder.

Step 3: Schedule It With Cron

To run the backup every day at 02:10, add this line to /var/spool/cron/crontabs/root:

10 2 * * * /vmfs/volumes/datastore1/ESXi_backup/esxi-backup.sh

The crontab file is read-only by default, so change its permissions before you edit it, or append the line with echo. Then restart the cron service so the change is picked up.

⚠️ Warning: Cron changes on ESXi are lost after a reboot. To make the schedule permanent, add the same commands (kill crond, append the cron line, start crond) to /etc/rc.local.d/local.sh above the final exit 0 line, then run /bin/auto-backup.sh to save that file into the host state.

Method 2: Back Up ESXi Host With vSphere CLI

vSphere CLI (vCLI) lets you manage ESXi hosts remotely from a Windows or Linux machine. It is a good fit if you like bash scripting and do not want to log in to each host. The examples use Ubuntu.

ℹ️ Info: vCLI is a legacy tool and is not being developed further for newer releases. It is still useful on older environments. For new setups, PowerCLI (Method 3) or the ESXi shell is the better option.

Install And Prepare vCLI

  1. Download vSphere CLI from VMware’s website to your Linux machine.
  2. Extract the archive and go to the extracted folder.
  3. Install the packages VMware lists as prerequisites (Perl and several libraries).
  4. Run the installer script, read and accept the licence, and let it install any required modules.
  5. If a Perl module fails to install, install it manually from the Perl interactive shell (perl -MCPAN -e shell) or with your package manager, then run the installer again.

Connect To The Host Securely

On the first connection vCLI will complain that the server SHA-1 thumbprint is not trusted. You can pass the thumbprint with the command, but typing the password in the command line is risky:

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

Leave out --password and the tool will prompt you. If you did type a password, run history -c afterwards to clear it. Better options are below.

Save The Thumbprint

/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

After this, you do not need to type the thumbprint on every command.

Use A Session File To Skip The Password

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

Then run commands with the session file:

esxcli --sessionfile /backup/192-168-101-208session system maintenanceMode get
🛑 Caution: A configuration file with VI_USERNAME and VI_PASSWORD in plain text also works, but anyone who can read that file can log in as root. Prefer the credential store or session file.

Back Up And Restore With vicfg-cfgbackup

# Save the configuration
vicfg-cfgbackup --server=192.168.101.208 --username=root -s /backup/esxi-208-config.tgz

# Restore it
vicfg-cfgbackup --server=192.168.101.208 --username=root -l /backup/esxi-208-config.tgz

If the UUID of the target host differs from the one in the backup, add the -f option to override the check. You can read the UUID of a running host with esxcfg-info -u. Put the host in maintenance mode before you restore.

Method 3: Back Up ESXi Host With PowerCLI

PowerCLI is a set of PowerShell cmdlets and the natural choice for Windows admins. It is also the easiest way to back up many hosts in one go.

Back Up

  1. Open PowerShell (or PowerCLI) as administrator.
  2. Connect to the host, or to vCenter if it manages the host, so you do not need to log in to each one separately.
  3. Run the backup and point it to a folder.
Connect-VIServer -Server 192.168.101.208 -User root

# One host
Get-VMHostFirmware -VMHost 192.168.101.208 -BackupConfiguration -DestinationPath C:\ESXiBackup

# Every host in vCenter
Get-VMHost | Get-VMHostFirmware -BackupConfiguration -DestinationPath C:\ESXiBackup

A pop-up asks for your credentials. Each host produces its own configBundle file in the destination folder.

Restore

Connect-VIServer -Server 192.168.101.208 -User root
Set-VMHost -VMHost 192.168.101.208 -State Maintenance
Set-VMHostFirmware -VMHost 192.168.101.208 -Restore -SourcePath C:\ESXiBackup\configBundle-esxi01.tgz -HostUser root -HostPassword (Read-Host 'Root password')
⚠️ Warning: Move the VMs off the host (or shut them down) before you restore. The host reboots automatically after the restore command. Version, build number and UUID must match the backup.

Method 4: Manual Backup And Recovery

Sometimes you cannot log in, or the host will not boot, so none of the command-line tools work. This is a hardware or software failure scenario, and it is where a manual approach helps. It is a last resort and works only if you already have a good backup file.

ESXi runs from a RAM disk. At boot, the host unpacks its saved configuration from an archive in the boot bank partition. That means the saved state can be copied or replaced by hand, with an SCP client such as WinSCP when the host is running, or from a live disc when it is not.

Manual Recovery Workflow

  1. Prepare the backup archive you made earlier with the shell, vCLI or PowerCLI and copy it to a USB drive.
  2. Boot the server from a live Linux CD/DVD or USB and open a terminal.
  3. List the disk partitions (fdisk -l or lsblk) and find the ESXi boot bank partition. It is usually a small partition of about 250 MB.
  4. Create a mount point and mount that partition.
  5. Inside it you will find the configuration file state.tgz. On a running host this folder appears as /bootbank.
  6. Copy your backup from the USB drive and extract it to find the matching state.tgz.
  7. Rename the original state.tgz (for example to state.tgz.old) and copy the backup version in its place.
  8. Unmount the partition, reboot, remove the live disc and boot from the ESXi disk.
🛑 Caution: Partition layouts differ between ESXi versions. Double-check which partition you are mounting before you write to it, and keep the original file renamed rather than deleted.

Which Method Should You Use?

Method Best For Needs Install? Can Be Automated? Difficulty
ESXi Shell Single hosts and quick backups No Yes (cron) Easy
vSphere CLI Linux admins on older setups Yes Yes (bash) Medium
PowerCLI Windows admins and many hosts Yes (PowerShell module) Yes (scripts) Easy to medium
Manual Hosts that will not boot No No Hard
💡 Tip: Use two methods together. A scheduled shell or PowerCLI backup for daily protection, plus a manual copy before every upgrade.

Do Not Forget Your Virtual Machines

A configuration backup rebuilds the host, not the workloads on it. Your VMs need their own protection:

  • Use a VM-level backup product that supports ESXi, so backups are agentless and consistent.
  • Export important VMs as OVF/OVA files for simple one-off copies.
  • Remember that a snapshot is not a backup. It lives with the VM and grows over time.
  • Follow the 3-2-1 idea: three copies, on two different media, with one stored off-site.

Related reading on the blog: recover data from a formatted flash drive, speed up a slow WordPress site without plugins and MBR vs GPT: which one is better.

Frequently Asked Questions

What is an ESXi configuration backup?

It is a small .tgz file (configBundle) that stores the host’s settings: networking, storage settings, users, licensing and advanced options. It does not contain your virtual machines or their data.

Does a configuration backup include my virtual machines?

No. It only protects the host settings. VMs live on datastores and need their own backup, such as a VM-level backup tool, OVF exports or storage replication.

How often does ESXi save its own configuration?

ESXi writes its running configuration to the boot bank automatically about once an hour. You can force a save at any time with the vim-cmd hostsvc/firmware/sync_config command.

Where is the configuration backup file created?

When you run the backup_config command, the host prints a download URL and places the bundle in the /scratch/downloads directory for a short time. Copy it to a datastore or another machine straight away.

Can I restore a backup to a different ESXi build?

No. The ESXi version and build number must match the backup. If the target host was reinstalled, install the same build first, then restore.

What if the UUID of the host has changed?

The restore checks the host UUID. If you are restoring to a rebuilt or replacement host, you can override the check with the force option (-f in vicfg-cfgbackup, -Force in PowerCLI where supported). Only do this when you are sure it is the right backup.

Does the host restart after a restore?

Yes. The host reboots automatically once the restore command runs, so put it in maintenance mode and move or shut down its VMs first.

Which method is best for scheduled backups?

A script in the ESXi shell run from cron works with no extra software. If you manage many hosts from Windows, a PowerCLI script that loops through every host is easier to maintain.

Is vSphere CLI still the right tool?

It still works on older environments, but VMware’s newer tooling focuses on PowerCLI and ESXCLI. For new setups, PowerCLI or the ESXi shell is the safer choice.

Is it safe to type the root password in a command?

It is not recommended. The password can end up in shell history and process lists. Use a credential store, a saved session or an interactive prompt instead, and clear history if you did type it.

Can I back up ESXi if the host will not boot?

Yes, if you already have a configuration bundle. You can boot a live Linux disc, mount the boot bank partition and replace the state file by hand. If you have no bundle, you will have to reinstall and reconfigure.

Where should I store the backup files?

Keep at least two copies: one off the host (a file server or cloud storage) and one offline. A backup stored only on the same datastore is lost if that datastore fails.

Conclusion

Now you know How To Backup VmwareESXi four different ways. The ESXi shell is the simplest, PowerCLI is the best for many hosts, vSphere CLI suits older Linux-based setups, and the manual method saves you when a host will not boot. Whichever you pick, back up before every change, keep copies off the host and test a restore at least once. Then pair it with a proper backup for your virtual machines.

Need help with servers, websites or SEO? Talk to the Aik Designs team and explore more guides in the Technology category.

About Author