Backup of a running container with vzdump

Vzdump is a utility to make consistent snapshots of running OpenVZ containers (and KVM virtual machines if you are using Proxmox VE). It basically creates a tar archive of the container's private area, which also includes the CT configuration files.

There are several ways to provide consistency:

Stop the CT during backup (very long downtime)

Use rsync and suspend/resume (minimal downtime)

Use LVM2 (no downtime)

Vzdump stores the backup on the disk in a single file. This file should go to a tape backup for archiving.

While the LVM solution is the cleanest, since it allows to create an online backup without having to stop or suspend the virtual machine, it is also the hardest to set up. There are a few dependencies you should be aware of before setting up your LVM:

You need to have at least 512MB free in your LVM volume group, to be able to create snapshots

The directory where you are writing your backup dumps to (usually /vz/dump) should be on a different volume group than the one you are taking a backup from (usually /vz/private)

As described above, you need to keep a few things in mind when creating your LVM partitions. In the example setup below, there are a total of 4 partitions:

/, which is hosting the default OS files, on a 10GB LVM logical volume

/boot, which is hosting the kernel and bootloader config, on a 512MB standard Linux partition

/opt, which is hosting the backup dump files, on a 100GB LVM logical volume

/vz, which is hosting all virtual machine files, on a 1.6TB LVM logical volume

All logical volumes are hosted on a 1.8TB volume group of which only 1.7TB is used by the above partitions and 100GB is unallocated.

In this setup the 100GB of free volume group space and 100GB of backup directory have been chosen to hold the snapshots and tar files that will be created when the virtual machine will be backed up. As specified above, only 512MB of snapshot space is needed, but it's better to be safe than having to resize your volumes at a later stage when disk space is not an issue. The same holds for the backup directory.

When trying to backup a virtual machine, creation of the snapshot can fail. This is because of a bug in VZDump.pm. In CentOS (and other RHEL derivatives), this file is located in /usr/share/perl5/PVE/VZDump.pm.

(not fixed in 1.2-4)
The rsync command used by vzdump to create the backup in suspend mode partially ignores the "--exclude-path" option.
In fact, even if the excluded paths won't appear in the final output, the whole VPS will be moved to the temporary directory, meaning that you need as much free disk space as your VPS size to use vzdump. It can be an issue in the case of a file server handling many files...

(fixed in 1.1-1)
vzdump will fail under Debian Etch in version 1.0-2 if it is invoked with parameter "--snapshot" and if the logical volume name contains a hyphen.

Workaround: One possible workaround is to rename the logical volume in question thus it doesn't contain any hyphen.
A bug report was sent to proxmox on 02 June 2008.
Other distributions or versions may be affected, too.