GhettoVCB

From Leo's Notes
Last edited on 16 July 2017, at 00:24.

ghettoVCB is a script that allows VMware ESXi hosts to backup virtual machines using snapshots without requiring the guest to shut down.

The drawback with this script is that it is unable to back up guests with existing snapshots.

Installation[edit | edit source]

Get the script from their GitHub repository:

You may either install it using their .vib package, or save the script somewhere accessible by the ESXi server.

Usage[edit | edit source]

Create a datastore (either NFS or disk) that you will backup to. For my usual use-case, I normally create a NFS share for backups which is also where I place the ghettoVCB script and configuration as well.

## /data/vm is exported for the ESXi server.
## Edit the ghettoVCB.conf as desired (optional)
## The backup_vms file contains all the VMs I wish to back up (see below)

leo@nas:/data/vm% ls
backup_vms  esxi-backup/  ghettoVCB.conf  ghettoVCB.sh*

leo@nas:/data/vm% cat backup_vms
CentOS 7 Web
Fedora Compute

To back up a machine named 'CentOS 7', run:

[root@server:/vmfs/volumes/ee8ff6f0-af4dbc98] sh ./ghettoVCB.sh -m "CentOS 7"

However, if you want to backup a set of virtual machines, create a text file containing the name of each virtual machine you wish to back up and then run:

[root@server:/vmfs/volumes/ee8ff6f0-af4dbc98] sh ./ghettoVCB.sh -f backup_vms

Scheduled Backups[edit | edit source]

You can add a cronjob on the ESXi server to automatically run ghettoVCB.

# vi /var/spool/cron/crontabs/root
## Add the job. Run at 5AM every Sunday
0    5    *   *   0   /vmfs/volumes/nas-vm/ghettoVCB.sh -g /vmfs/volumes/nas-vm/ghettoVCB.conf -f /vmfs/volumes/nas-vm/backup_vms

You may want to make this persistent by editing the startup script to insert this job.

# vi /etc/rc.local.d/local.sh
## Add the following above exit 0
/bin/echo "0    5    *   *   0   /vmfs/volumes/nas-vm/ghettoVCB.sh -g /vmfs/volumes/nas-vm/ghettoVCB.conf -f /vmfs/volumes/nas-vm/backup_vms" >>  /var/spool/cron/crontabs/root

You shouldn't need to stop/start crond, but in case you do:

/bin/kill $(cat /var/run/crond.pid)
/bin/crond