Backup VMware ESXi to Linux with ZFS

Lowest budget backups for your free VMware ESXi hypervisor.

- Install server with bunch of disks and Ubuntu 14.04. Use mdraid-1 for OS disks.

- Install ZFS support
apt-add-repository -y ppa:zfs-native/stable
apt-get update
apt-get -y install ubuntu-zfs

- Create RAID-Z2 (double parity) zpool
zpool create data raidz2 \
         /dev/disk/by-id/ata-ST31000340NS_9QJ6ZHJJ \
         /dev/disk/by-id/ata-ST31000340NS_9QJ718FG \
         /dev/disk/by-id/ata-WDC_WD1002FBYS-02A6B0_WD-WMATV7379900 \
         /dev/disk/by-id/ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0857564 \
         /dev/disk/by-id/ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0945918 \
         -o ashift=12 -o failmode=continue

- Create filesystem with compression (and deduplication if you feel brave)
zfs set atime=off data
zfs create data/backup
zfs set compression=on data/backup
#zfs set dedup=on data/backup

- Install NFS server
apt-get -y install nfs-kernel-server

- Export new ZFS filesystem to VMware ESXi
mkdir /data/backup/esx
echo "/data/backup,async,no_subtree_check,no_root_squash)" >>/etc/exports
exportfs -rv
service nfs-kernel-server restart

- Mount new NFS export to VMware (Config > Storage > Add Storage > NFS > enter Linux server IP, /data/backup as path and BACKUP as name.

- Create SSH key on Linux, just answer with enter to all questions

- Copy /root/.ssh/ to /data/backup
cp /root/.ssh/ /data/backup

- Enable SSH remote access to ESXi, see VMware docs for details if you haven't already done this
- Login to ESXi using SSH
ssh root@

- Enable passwordless SSH logins (following commands are entered on ESXi shell)
mv /vmfs/volumes/BACKUP/ /etc/ssh/keys-root/authorized_keys
chmod 0400 /etc/ssh/keys-root/authorized_keys

- Logout from ESXi shell and reconnect using SSH. You should now be able to login without password.

- Install ghettoVCB (enter rest of command on Linux side, not esx shell)
cd /data/backup
tar xvzf master.tar.gz
mv ghettoVCB-master scripts
rm -f master.tar.gz

- Create config file and keep weekly backups for entire year
mv ghettoVCB.conf ghettoVCB.conf.dist
cat <<'_EOF_'>ghettoVCB.conf

- Schedule backups
cat <<'_EOF_'>>/etc/crontab
# Backup ESXi every Saturday night
5 1 * * Sat root (ssh root@ -C '/vmfs/volumes/BACKUP/scripts/ -a -g /vmfs/volumes/BACKUP/scripts/ghettoVCB.conf') >>/data/backup/esx/logi 2>>/data/backup/esx/logi
service cron restart

- Do first run manually so we don't need to wait until Saturday
ssh root@ -C '/vmfs/volumes/BACKUP/scripts/ -a -g /vmfs/volumes/BACKUP/scripts/ghettoVCB.conf'