Using hotbackup on Linux with LVM
2010-10-07 14:34
Write commentHaving 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 :
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 :
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:
lvm sysadmin linux backup
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


