old blog,

Disk snapshot backup in Linux

Izhar Firdaus Izhar Firdaus Follow Support Feb 11, 2009 · 1 min read
Disk snapshot backup in Linux
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

From #myoss @ freenode.net
<kaeru> what do linux people do for full backups?
<kaeru> freebsd there is dump/restore
<kaeru> do people use that for ext3 still or is there a better way?
<sweemeng> kaeru rsync?
<kaeru> I mean disk level snapshots

FreeBSD ufs2, as what we use in Inigo's Gambit, can easily create snapshots of a live filesystem using dump. However, ext2/ext3 used widely in Linux does not have such feature (as far as I know). But for those who want such feature, fear not, there is a feature in LVM called snapshots which more or less provide a similar thing.

Fedora/RHEL/CentOS users might be familiar with the term LVM as the 3 distros uses LVM by default in their default installation partitioning scheme. Some people think LVM by default is a painful thing, but to me, its the opposite (until you need to get it to work with dualboot windows+linux env).

Back to the topic, here's a little guide for those who want to do a full disk image backup using LVM on a live system.


- A system that uses LVM as its partitioning scheme (obviously).
- The filesystem must be a LVM managed partition
- Some free unallocated space in the LVM VolumeGroup

This guide will take the assumption the partition you want to backup is `/dev/VolGroup/MyVolume`.

Creating a Snapshot

Creating a snapshot is pretty straightforward.
/usr/sbin/lvcreate -s -L512M -p r -n SnapshotVolume /dev/VolGroup/MyVolume

This will create a readonly snapshot of MyVolume as /dev/VolGroup/SnapshotVolume with 512MB extension.

Backing Up

Once a snapshot is created, you may do anything you wish with `/dev/VolGroup/SnapshotVolume`. eg: use dump or dd the snapshot, or simply mount the snapshot and tar its contents.

Cleaning Up

Once you've done doing your backup, you may remove the snapshot easily using.
/usr/sbin/lvremove /dev/VolGroup/SnapshotVolume

Ok thats it. Have fun.

For more reading, I recommend the LVM-HOWTO at tldp.org
Written by Izhar Firdaus Follow Support
I'm a system architect, data engineer and developer advocate with passion in Free / Open Source software, entrepreneurship, community building, education and martial art. I take enjoyment in bridging and bringing together different FOSS technologies to help businesses and organizations utilize IT infrastructure to aid and optimize their business and organizational process.

Code Quality Measurement - WTF/m

- Izhar Firdaus -

In old blog, Feb 11, 2009

« Previous Post

Dear Lazywebs : SSH on low bandwidth connections

Anybody got tips on how to make SSH on low bandwidth / bad connections (eg: 0-4KBps) more bearable?- Izhar Firdaus -

In old blog, Feb 11, 2009

Next Post »