Skip to content

Backup Solutions for Free ESXi

VMware offers a free version of their vSphere Hypervisor with some limitations like the lack of vCenter support. Another limitation is that APIs are read-only, so it's not possible to use the Data Protection API aka. VADP to make Backups.

Creating backups of Virtual Machines is also important on standalone ESXi hosts. The API limitation makes it impossible to create incremental CBT aided backups, but it's not impossible to create full copies of virtual machines. The post explains the technique to create backups and takes a look at solution that use these techniques.

Poor Man's Backup (The Basics)

All Virtual Machines are just files on datastores. The most unsophisticated backup method would be to simply make a copy of all files. This method works not only with the ESXi Hypervisor, but also with VMware Workstation or older products like GSX or VMware Server. Many years ago, this was my first method of creating backups of running Virtual Machines. But wait - Can you just copy a running Virtual Machine? No! You can't copy the Virtual Disk file while it is mapped to the Virtual Machine mode:

"cp: can't open 'web01-flat.vmdk': Device or resource busy"

The challenge is to make the disk readonly while the Virtual Machine is running, without affecting the operating system running in the Virtual Machine. Here comes another technology in place: Snapshots. A snapshot is a preserved state of the virtual machine where you can return to later. A common misinterpretation is that when you create a snapshot the system copies the defined state to another location. This is not how a VMware snapshot works. When you create a snapshot, the original virtual disk file is transformed into readonly mode. To allow the virtual machine to work while the disk is in read only mode, all write IOs are stored in another file known as "Delta File".

The answer to the problem is: Create a snapshot, copy the virtual disk, delete the snapshot. Here is the full process of making working backups of running Virtual Machines:

  1. SSH to the ESXi Host
  2. Copy VM configuration files (.vmx, .nvram, .vmsd, .vmdk). The ".vmdk" is only the virtual disk descriptor file, so it's possible to make a copy. The actual disk is *-flat.vmdk. I'm copying all files to a nfs share mounted as datastore.
    cp /vmfs/volumes/datastore/web01/web01.vmx /vmfs/volumes/nfs/web01-backup/web01.vmx
    cp /vmfs/volumes/datastore/web01/web01.nvram /vmfs/volumes/nfs/web01-backup/web01.nvram
    cp /vmfs/volumes/datastore/web01/web01.vmsd /vmfs/volumes/nfs/web01-backup/web01.vmsd
    cp /vmfs/volumes/datastore/web01/web01.vmdk /vmfs/volumes/nfs/web01-backup/web01.vmdk
  3. Create a Snapshot with the vSphere Client or by command line (locate vmid with "vim-cmd vmsvc/getallvms" and make a snapshot with "vim-cmd vmsvc/snapshot.create [VmId] [snapshotName] [description] [includeMemory] [quiesced]")
    vim-cmd vmsvc/getallvms
    vim-cmd vmsvc/snapshot.create 2 backup poor-mans-backup 0 0
  4. Copy the virtual disk
    cp /vmfs/volumes/datastore/web01/web01-delta.vmdk /vmfs/volumes/nfs/web01-backup/web01-delta.vmdk
  5. Delete the Snapshot with the vSphere Client or by command line (vim-cmd vmsvc/snapshot.removeall [VmId])
    vim-cmd vmsvc/snapshot.removeall 2

The reason why I copy configuration files prior to make the snapshot is because the snapshot is documented in the configuration file and the Virtual Machine will not power on when the snapshot file is missing. This can be fixed in the configuration, but it's easier to simply copy the correct configuration.

Restore: To restore the Virtual Machine register it on the ESXi Host "Add to inventory" and power it on.
add-vm-to-inventory

The Virtual Machine notices that it has been moved. If you want to restore the original VM, select "I Moved It" and it will preserve its UUID and MAC addresses. If you want to run both VMs on the same ESXi host, select "I Copied It", and you can run both at the same time.
vm-message-vm-moved-or-copied

Poor Man's Backup 2.0 (The viable solution)

The copy process of the above method works everywhere, but it is very slow and can be optimized. The cp command simply copies the entire file, including the unused space of virtual disks which is represented as zeros. ESXi hosts have a tool that understands virtual disks and ignores unused blocks during copy processes. It also allows to change the output format to thin, which is great for backups:

vmkfstools -i [sourceDisk] [targetDisk] -d [diskformat]

The following script is a working example to backup a Virtual Machine on a Free ESXi host:

#!/bin/sh
mkdir -p /vmfs/volumes/datastore1/web01-backup/

cp /vmfs/volumes/datastore1/web01/web01.vmx /vmfs/volumes/datastore1/web01-backup/web01.vmx
cp /vmfs/volumes/datastore1/web01/web01.nvram /vmfs/volumes/datastore1/web01-backup/web01.nvram
cp /vmfs/volumes/datastore1/web01/web01.vmsd /vmfs/volumes/datastore1/web01-backup/web01.vmsd

vmid=$(vim-cmd vmsvc/getallvms | grep web01 | awk '{print $1}')
vim-cmd vmsvc/snapshot.create $vmid backup 'Snapshot created by Backup Script' 0 0

vmkfstools -i /vmfs/volumes/datastore1/web01/web01.vmdk /vmfs/volumes/datastore1/web01-backup/web01.vmdk -d thin

vim-cmd vmsvc/snapshot.removeall $vmid

The scipt is very basic, without error checking and static. It's intended to demonstrate the process.

ghettoVCB by William Lam

ghettoVCB is a long known backup solution that works from ESXi 3.5 until ESXi 6, created by VMware employee William Lam. It's a comprehensive script that runs on the ESXi host and creates backups using the method explained above. It does not use the VMware backup API, so it works with free ESXi.

Download ghettoVCB from GitHub (Press "Raw" to download the File) and install the .vib:

esxcli software vib install -v /vmfs/volumes/datastore1/vghetto-ghettoVCB.vib -f

ghettoVCB can be configured with configuration files. A full documentation can be found here: ghettoVCB Documentation. For this example, I've created a basic configuration and only changed the backup volume:

VM_BACKUP_VOLUME=/vmfs/volumes/datastore1/BACKUP

Start the Backup with the -a parameter, to backup all VMs on the host, and the ghettoVCB.conf:

/opt/ghettovcb/bin/ghettoVCB.sh -a -g ghettoVCB.conf

This will create a backup of all Virtual Machines running on the ESXi host to the backup directory. To restore, you can simply add the .vmx file to the ESXi inventroy.

Pro/Cons
+ Available as VIB package, easy installation
+ Mature solution with a large feature set
+ Good documentation. Easy to make cronjobs that are persistent through a reboot.
- Due to it's large feature set, the deployment is not self-explaining
- Requires basic shell skills

XSIBackup

XSIBackup is another free script that runs on the ESXi host and backups running virtual machines on free ESXi Hosts. Features:

  • Performs hot backups
  • Does not use VADP
  • Supports Cronjobs
  • Supports Rsync to mirror backups to a second ESXi

The tool can be downloaded here. Unzip it, make it executable and it its ready to run. No further configuration is required. To backup all VMs running on the ESXi host, just start the script with the following parameters:

./xsibackup --backup-point=/vmfs/volumes/datastore1/BACKUPS --backup-type=running

The full documentation is available here.

Pro/Cons
+ Large Feature Set
+ Very quick to setup (5 minutes to first backup)
- Download requires a (free) key
- Requires basic shell skills

HPE VM Explorer (Trilead VM Explorer)

HPE VM Explorer is available as free edition here. The windows based software is configured and managed with a web interface and works with the free ESXi. If you want to create a backup of your standalone ESXi ot your Windows machine, this is your tool of choise. Of course it also supports backups to the local ESXi host.
hpe-vm-explorer

Pro/Cons
+ Easy installation
+ Also supports vCenter and API based Backups
+ No shell skills required
- Requires an additional server for the application

Other Tools

The following tools are, according to their documentation, also capable of creating backups of Virtual Machines running on Free ESXi:

16 thoughts on “Backup Solutions for Free ESXi”

  1. Pingback: [Sammelthread] HP ProLiant ML10 v2 G3240/i3-4150/E3-1220v3/E3-1241v3 - Seite 33

  2. Pingback: ESX / ESXi - Hilfethread - Seite 218

  3. For ESXi 5.5+ you can use Extrasphere solution. They supports free ESXi and have a free HotClone and very cheap HotMirror features. The last one a bit like Zerto but simpler.

  4. I have a question. I have a VM which has already a snapshoot from a few weeks ago.

    If I do the backup of the VM, and then delete that snapshoot, will I be able to still goback to the snapshoot on the Backup VM instance? Thanks very much.

  5. Great post. Now, I have a couple of questions:

    What method is better? the vmkfstools o the Poor Mans?

    I managed to get the vmkfstools working, but have not restored it on another ESXi instance.

    The challenge I have now is that the clone is super big 20 gigs, so moving this files is a pain.

    Is there any option to compress so I can move faster and the uncompress on the new instance?

    Thanks and Happy New Year!

    Ricardo Malla

    1. A vmkfstools based solution is better because you can backup to thin vmdks. I think the best way is to use an NFS as the backup target so you don't have to copy it around when you need a restore. Of course, this does not work when you are running local storage only.

      Of course you can also compress the vmdk file for example with bzip2:
      # bzip2 disk.vmdk
      decompress with:
      # bzip2 -d disk.vmdk.bz2

  6. Really great post. Poor Man's Backup 2.0 is a great solution. vmkfstools is a great little thing!

    I then did a couple more steps, specifically:

    tar -czf guest1.tar.gzip ./guest1/*

    Then I created a NFS datastore and moved the file there.

    The resulting compressed file is 5.5GB, down from the 100GB original thick vmdx files.

    The only thing to clarify is that if a guest has multiple disks, then you need to create the copy of each disk. e.g.

    vmkfstools -i /vmfs/volumes/datastore1/guest1/guest1.vmdk /vmfs/volumes/datastore1/backups/guest1/guest1.vmdk -d thin
    vmkfstools -i /vmfs/volumes/datastore1/guest1/guest1_1.vmdk /vmfs/volumes/datastore1/backups/guest1/guest1_1.vmdk -d thin

  7. Thank you so much for the info, I had difficulties in deciding which backup software to use for an ESXi host, I can confirm that VSquare Backup works but you need a windows machine to be open, GhettoVCB should work but I get an 'out of memory' error during backup, XSIBackup Works perfectly and I managed to start it from a remote linux using screen->ssh->xsibackp

  8. Thanks for this great resource William! It's nice to have a viable backup solution for my home lab. The only problem I'm having is when I install any ESXi updates, all my GhettoVCB settings, including corncobs are deleted. Is there a way to preserve my GhettoVCB environment when installing ESXi updates?

    1. Where is your config and how to you configure cronjobs?

      Place your config on a Datastore and set the cronjob properly in /etc/rc.local.d/local.sh and it definitely should persist updates. Here is an example of creating a ghettoVCB cronjob using local.sh. Just add the following before "exit 0".

      /bin/echo "0 * * * * /opt/ghettovcb/bin/ghettoVCB.sh -f /vmfs/volumes/[datastore]/ghettoVCB/vmlist.conf -g /vmfs/volumes/[datastore]/ghettoVCB/ghettoVCB.conf > /vmfs/volumes/[datastore]/ghettoVCB/_log/\$(hostname -s)-\$(date +%Y-%m-%d-%H%M).log" >> /var/spool/cron/crontabs/root

Leave a Reply to Holylander Cancel reply

Your email address will not be published. Required fields are marked *