Back Up (And Restore) LVM Partitions With LVM Snapshots
Back Up (And Restore) LVM Partitions With LVM SnapshotsVersion 1.1 This tutorial shows how you can create backups of LVM partitions with an LVM feature called LVM snapshots. An LVM snapshot is an exact copy of an LVM partition that has all the data from the LVM volume from the time the snapshot was created. The big advantage of LVM snapshots is that they can be used to greatly reduce the amount of time that your services/databases are down during backups because a snapshot is usually created in fractions of a second. After the snapshot has been created, you can back up the snapshot while your services and databases are in normal operation. I will also show how to restore an LVM partition from a backup in an extra chapter at the end of this tutorial. This document comes without warranty of any kind! I do not issue any guarantee that this will work for you!
1 Preliminary NoteI have tested this on a Debian Etch server with the IP address 192.168.0.100 and the hostname server1.example.com. It has two hard disks:
I have created a Debian Etch VMware image that you can download and run in VMware Server or VMware Player (see http://www.howtoforge.com/import_vmware_images to learn how to do that). It has the same specifications as my test system from above. The root password is howtoforge. Using that VMware image, you can do the exact same steps than me in this tutorial to get used to using LVM snapshots. To restore the / partition from your backup (covered in the last chapter of this tutorial) you need a Linux Live-CD that supports LVM, such as Knoppix or the Debian Etch Netinstall CD which you can use as a rescue CD if you specify rescue at the boot prompt. I will use the Debian Etch Netinstall CD in this example (the list of mirrors is available here: http://www.debian.org/CD/http-ftp/ - I downloaded this one: http://ftp.de.debian.org/debian-cd/4.0_r0/i386/iso-cd/debian-40r0-i386-netinst.iso). To create a backup of the / partition I will proceed as follows: I will create a snapshot of the / partition, and afterwards I will create a backup of the snapshot (instead of the actual / partition!) on the /backups partition (of course, you can store that backup wherever you want - instead of creating an extra /backups LVM partition, you could also use an external USB drive). The backup can be made using your preferred backup solution, e.g. with tar or dd. Afterwards, I'll destroy the snapshot because it isn't needed anymore and would use system resources. You don't necessarily need a second HDD for the snapshots - you can use the first one provided you have enough free (unpartitioned) space left on it to create snapshots on it (you should use the same space for the snapshots that you use for the partition that you want to back up). And as mentioned before, you can use a USB drive for backing up the snapshots. To learn more about LVM, you should read this tutorial: http://www.howtoforge.com/linux_lvm
2 Create The /backups LVM Partition(If you'd like to store your backups somewhere else, e.g on an external USB drive, you don't have to do this.) Our current situation is as follows: pvdisplay server1:~# pvdisplay vgdisplay server1:~# vgdisplay lvdisplay server1:~# lvdisplay fdisk -l server1:~# fdisk -l So /dev/sda contains the logical volumes /dev/server1/root (/ partition) and /dev/server1/swap_1 (swap partition) plus a small /boot partition (non-LVM). (BTW, /dev/server1/root is the same as /dev/mapper/server1-root on Debian Etch. The first is a symlink to the second; I will use both notations in this tutorial. The same goes for /dev/server1/swap_1 and /dev/mapper/server1-swap_1.) I will now create the partition /dev/sdb1 and add it to the server1 volume group, and afterwards I will create the volume /dev/server1/backups (which will be 30GB instead of the full 60GB of /dev/sdb so that we have enough space left for the snapshots) which I will mount on /backups: fdisk /dev/sdb server1:~# fdisk /dev/sdb pvcreate /dev/sdb1 Now let's mount our /dev/server1/backups volume on /backups: mount /dev/mapper/server1-backups /backups To have that volume mounted automatically whenever you boot the system, you must edit /etc/fstab and add a line like this to it: vi /etc/fstab
Now our new situation looks like this: pvdisplay server1:~# pvdisplay vgdisplay server1:~# vgdisplay lvdisplay server1:~# lvdisplay
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
One number. one voicemail. Seize the lead with Sprint. Learn more
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning
Learn benefits of Simpana software.
View the Gartner Video
Sprint 4G - The Ultimate Mobile Broadband
Click here
SAP-Business Objects Crystal Reports Server
Complete reporting without hidden costs. Free Trial




print: 

Recent comments
2 hours 59 min ago
10 hours 16 min ago
11 hours 4 min ago
11 hours 18 min ago
16 hours 52 min ago
22 hours 57 min ago
1 day 3 hours ago
1 day 3 hours ago
1 day 11 hours ago
1 day 12 hours ago