Linux Backup – Should LVM Snapshots Be Used with Rsnapshot?

backuplinuxlvmrsnapshot

I manage a CentOS 4.8 server for a small workgroup. Last year I converted the filesystem to LVM over software RAID (RAID 1, two mirrored drives).

I now have the following filesystems on LVM/RAID:

/dev/mapper/vg-home   619G  231G  358G  40% /home
/dev/mapper/vg-tmp    7.9G   55M  7.5G   1% /tmp
/dev/mapper/vg-usr    7.9G  2.7G  4.9G  36% /usr
/dev/mapper/vg-var    7.9G  3.1G  4.5G  42% /var

To back these filesystems up, I use rsnapshot and a couple of external 2TB USB drives that I rotate weekly. In practice that has worked very well. I have rsnapshot configured to do snapshots every four hours.

Given that configuration, should I also consider doing LVM snapshots? Are LVM snapshots more efficient? Could I be doing them more often than the rsnapshot backups every 4 hours without significantly impacting system performance?

I am aware that LVM snapshots could be used to ensure database consistency for backups, however this server doesn't run a database so that isn't really a concern.

It seems like there might be a way to do both LVM and rsnapshot backups in a complimentary fashion but I am unable to suss it out.

Best Answer

I'm a big fan of snapshots for backups, but I typically use them in the manner you'll find described for LVM snapshots -- Make a snapshot, mount it somewhere, back up the snapshot with your favorite backup tool (I like Bacula), then get rid of the LVM snapshot. Ideally this backup goes somewhere off-site

This dovetails very well with rsnapshot: Your rsnapshot snapshots can be instantly-available local backups, and they can also be captured in the off-site backup of the filesystem that you make from the LVM snapshot.

LVM snapshots are very similar to BSD UFS/FFS snapshots in that they store the deltas between when the snapshot was taken and the current system state: This means that performance will degrade as the snapshot and the main disk grow further out of sync, and there's some overhead for each snapshot you're maintaining (any change to the disk has to be tracked so the snapshot knows about it).
In practice this overhead isn't significant unless your disk changes frequently and you're keeping snapshots around for a long time.

See http://tldp.org/HOWTO/LVM-HOWTO/snapshots_backup.html for more on using LVM snapshots for backups (painted with the same broad strokes as what I just said).


Incidentally LVM (or UFS) snapshots are also a great "save game" kind of thing if you're about to do something REALLY DANGEROUS to a production server, but that's well outside the scope of your question