6c4a91744a9f857f00ddd8802edb7465

Using hotbackup on Linux with LVM

2010-10-07 14:34

Write comment
Having a write-intensive database, backuping it with usual tools is no longer possible since backup action can take a while and data can be altered in the meanwhile ...

A solution to this is to use LVM snapshoting to do consistent backup.

Let's do an example, i'm about to hotbackup my /home :
 # grep home /etc/mtab
/dev/mylaptop/home-lv /home xfs rw,noatime 0 0 
In order to get a consistent image of the /home filesystem in the snapshot, we need to freeze it, so the log journal is flushed and no more accesses are done to it.
 # xfs_freeze -f /home
# lvcreate -L5G -s -n myhome_snapshot -s /dev/mylaptop/home-lv
# xfs_freeze -u /home
 
This will create snapshot named myhome_snapshot for Logical Volume mylaptop/home-lv. You should specify enough of undo space to hold modifications during backup process - I've specified 5GB in this case. If your undo size is not large enough snapshot will get invalidated.

You dont need more space (except those 5 gigs) on the box to create the snapshot, this is the magic part of all this ;)

So now, let's mount the snapshot and backup it :
 # mount -o ro,nouuid /dev/mylaptop/myhome_snapshot /mnt/mysnapshot 
Since the snapshot is an image of the orginal filesystem, it will get the same UUID and mounting it will fail since you cant mount duplicate UUID, that's why i use the nouuid option.
Although i think this is an XFS-specific mount option (to be confirmed)

Once mounted, you can do whatever you want on the cloned /home.

Dont forget to unmount the snapshot and remove it:
 # umount /mnt/mysnapshot
# lvremove -f /dev/mylaptop/myhome_snapshot 


Similar posts
This post will cover howto write a HelloWorld Java application and deploy it to the Google App Engine. The fact that google is offering us the ability to share its platforms made me looking forward to taste piece of that pie.
Back on track, let me first tell you that Ant will look for a file named build.xml by default. After that, it’ll do exactly what it was told to do, so let’s edit that helloworld/build.xml file to make things work:

0 Comments


Send your comment
Type the characters you see in the picture below
Try a new code