Changes

Jump to: navigation, search

Backup of a running container with vzdump

2,476 bytes added, 13:10, 16 March 2012
no edit summary
Note that using LVM2 and vzdump to create snapshots requires 512Mb of free space in your VG as described [http://weblogs.amtex.nl/index.php?blog=2&title=using_vzdump_snapshot_to_backup_without_downtime&more=1&c=1&tb=1&pb=1 here].
 
=== Set-up LVM ===
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 the volume group that is hosting your virtuals (usually <code>/vz/private</code>)
* The directory where you are writing your backup dumps to (usually <code>/vz/dump</code>) should be on a different volume group than the one you are taking a backup from
* There is a bug in <code>VZDump.pm</code> that can make the snapshot creation fail
 
==== Partitioning ====
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:
 
* <code>/</code>, which is hosting the default OS files, on a 10GB LVM logical volume
* <code>/boot</code>, which is hosting the kernel and bootloader config, on a 512MB standard Linux partition
* <code>/opt</code>, which is hosting the backup dump files, on a 100GB LVM logical volume
* <code>/vz</code>, 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.
 
==== Fixing VZDump.pm ====
When trying to backup a virtual machine, creation of the snapshot can fail. This is because of a bug in <code>VZDump.pm</code>. In CentOS (and other RHEL derivatives), this file is located in <code>/usr/share/perl5/PVE/VZDump.pm</code>.
 
On line 622, you will find the following:
 
if ($line =~ m|^\s*(\S+):(\S+):(\d+(\.\d+))M$|) {
 
Replace this with:
 
if ($line =~ m|^\s*(\S+):(\S+):(\d+([\.,]\d+))[mM]$|) {
 
Save and close the file. Snapshots will now work with <code>vzdump</code>
 
==== Example ====
Since in the above example we have relocated the dump directory, you will need to run backups with a command similar to the following:
 
vzdump --dumpdir /opt/backupdir --snapshot 101
=== Restore ===
2
edits

Navigation menu