Skip to main content
FileSystemsSUSE

LVM Snapshots

By October 21, 2013September 12th, 2022No Comments

In previous tutorials we have look at managing LVM file-systems. In this article we will look at using snapshots with LVM to act as part of a backup solution. Maybe, you have a database or mail systems that have to be backup up but without special agents that may be costly they cannot be backed up online? An LVM snapshot can help you here. When we create a snapshot volume we freeze the file-system in time. We have the live system and then the snapshot. The snapshot is created instantly, not matter the size, only changes to the snapshot target need to be written to the snapshot volume. To be clear on this changes are not written to the snapshot volume but any changed file on the snapshot target is then copied to the snapshot volume whilst the snapshot volume is active. This way we have a “point in time” file system that represents the original LVM volume target at the stage the snapshot was taken. Backups can be taken from the LVM snapshot whilst your database or mail system accesses the live system. The commands following create a snapshot volume of 100M for the original logical volume data. We then mount the backup and create an archive with tar, un-mount and delete the LVM backup.

	lvcreate -L 100M -s -n backup /dev/vg1/data
	mount /dev/vg1/backup /mnt
	tar -czvf /tmp/backup.tgz /mnt/
	umount /mnt
	lvremove /dev/vg1/backup