-   Linux - Server (
-   -   lvm snapshot for backup (

eco 03-09-2009 06:29 AM

lvm snapshot for backup
Hi guys,

I have a Xen server which hosts a DomU mail server. The DomU is on a LV.

I'd like to use snapshots to backup the DomU but have a few questions I hope people can clarify.

1) Chosing the filesystem
I can confirm that doing a snapshot of a running ext3 system will lead to errors when booting the snapshot. The errors don't seem to be major but I'd like to avoid any risk. I hear some people use XFS to get arround that by doing a xfs_freeze before the snapshot. What do you think, use, recommend?

2) Snapshots
I read the following:

Full snapshot are automatically disabled
If the snapshot logical volume becomes full it will be dropped (become unusable) so it is vitally important to allocate enough space. The amount of space necessary is dependent on the usage of the snapshot, so there is no set recipe to follow for this. If the snapshot size equals the origin size, it will never overflow.
I'd like to understand what they mean by that? How can the image of a LV increase in size? Is it not an image in time?

Any help would greatly be appreciated.

eco 03-10-2009 03:38 AM


It looks like the snapshot keeps a record of all changes done on the original LV from the time of the snapshot... but for what purpose?

DaveG 03-12-2009 04:53 AM

A snapshot is not a mirror image of the target volume. It works more like a revision control system - the snapshot volume keeps a list of changes that have to be undone on the target volume to take it back to the point the snapshot was taken.

Every change made to the target volume is recorded in the snapshot as the original is updated, so the snapshot volume grows in relation to update activity, eventually filling the snapshot volume. Once this happens there is no way to record new changes and LVM can no longer get back to the snapshot point and invalidates the snapshot volume rather than crash.

Using a snapshot for backup still requires that the target volume is "quiescent". In this case your mail server software must flush everything to disk and pause before taking the snapshot to ensure that you accurately capture the full application state rather than just what happens to be on disk at the time - LVM doesn't know about locking etc. The benefit is that the application can start running again as soon as the snapshot is taken. This is much quicker that a full backup or mirror operation.

Hope this helps.


eco 03-15-2009 04:13 AM

Hi DaveG,

Sorry for the late reply. Yes, most useful indeed.

I have a couple of questions left now, pointers to documentation are still welcome :)

If a snapshot is a point in time and is there to allow us to go back to the time of a snapshot...

After taking a snapshot:
1) If I want to run a test, do I run it on the original LV or the snapshot?
2) How do I use the snapshot to return to a state before the test was made (time of snapshot).

What I did was, snapshot, mount snapshot instead of original LV, if ok, remove snapshot and do the same on original LV... but it seems all wrong now.

DaveG 03-15-2009 06:18 AM

The best documentation I have found is the LVM HOWTO at - Section 3.8 "Snapshots" and 13.4 "Taking a Backup Using Snapshots".

For testing something out with LVM2, create the snapshot and mount it in place of the original, run the test and, if all went well, discard the snapshot, re-mount the original and run again for real.

This way you side-step the issue of rolling back the original volume as it is unchanged during the testing, just like a quick mirror/backup copy. So you are "doing the right thing".


eco 03-15-2009 07:27 AM

Thanks for the reference and the thumbs up for my method. :)

All times are GMT -5. The time now is 12:25 PM.