Linux LVM Snapshot


Read only

Firstly an LVM snapshot volume is created. This snapshot volume collects changes to blocks in the original volume. The blocks that are updated are recorded in an exception table. When a backup is initiated the unchanged blocks are copied from the original LV, any changes to the original LV are recorded in the exception table and the blocks placed into the snapshot volume. The backup then finds these changed blocks in the snapshot volume via the exception table, therefore getting a consistent backup. The snapshot LV needs to be removed after the backup to prevent it from filling up due to continued changes.

The commands to complete a snapshot of an LV are shown below, the VG and LV will need to be changed to suit your environment.


lvcreate -L100M -s -n datalv_snap /dev/datavg/datalv
mkdir /mnt/datalv_snap
mount /dev/datavg/datalv_snap /mnt/datalv_snap
cp or rsync from /mnt/datalv_snap

umount /mnt/datalv_snap
lvremove /dev/datavg/datalv_snap