Thursday 15 April 2010

VMWare ESXi backups with VSphere

With VSphere purchased you can run backups over the network of virtual machines without taking them offline. The downside is that this will only be a crash consistent backup, although you can do things to improve this. The process works by taking a snapshot of the VM, then backing up the snapshot while the machine is still running. Once done the snapshot is merged back in to the running VM.

The command to run is (from "c:\program files\VMware\VMware Consolidated Backup Framework" by default):
# vcbmounter -h <vsphere host> -u <username> -a name:<VM Machine Name> -r <Local backup directory> -t fullvm -m nbd -M1
The command above will prompt for your password on the command line, you can include it in the command if you want to leave your password in the logs in plain text.

-a name: - This uses the VM name shown in VSphere (case sensitive) and will allow you to backup VM's which are powered off. Other options allow you to use the network name or IP of the Virtual Machine, but these require the VM to be on.

-t fullvm - the other option is to mount the VM so you can acces the files in the filesystems. Full VM gives you a VMWare image you can import elsewhere.

-M 1 - This sets the monolithic flag giving one big file for the filsystem. Otherwise it would split the filesystem into 2GB chunks

Earlier I mentioned that this backup would only be crash consistent. You can reduce potential problems by installing VMWare Tools to the guest VM, and by setting up scripts which the backup process can run before the snapshot to unmount databases etc.  For example you could turn off any databases, do the snapshot then turn the databases back on - databases would only be off for a couple of minutes and the backup would not risk corrupted database tables.

mountvm gives access to the guest file system remotely so you can backup specific files
vcbvmname lists details of all VM's on a server