3 Create An LVM Snapshot Of /
Now it's time to create the snapshot of the /dev/server1/root volume. We will call the snapshot rootsnapshot:
lvcreate -L10G -s -n rootsnapshot /dev/server1/root
The output of
lvdisplay
should look like this:
server1:~# lvdisplay
--- Logical volume ---
LV Name /dev/server1/root
VG Name server1
LV UUID UK1rjH-LS3l-f7aO-240S-EwGw-0Uws-5ldhlW
LV Write Access read/write
LV snapshot status source of
/dev/server1/rootsnapshot [active]
LV Status available
# open 1
LV Size 9.30 GB
Current LE 2382
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:0
--- Logical volume ---
LV Name /dev/server1/swap_1
VG Name server1
LV UUID 2PASi6-fQV4-I8sJ-J0yq-Y9lH-SJ32-F9jHaj
LV Write Access read/write
LV Status available
# open 2
LV Size 464.00 MB
Current LE 116
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:1
--- Logical volume ---
LV Name /dev/server1/backups
VG Name server1
LV UUID sXq2Xe-y2CE-Ycko-rCoE-M5kl-E1vH-KQRoP6
LV Write Access read/write
LV Status available
# open 1
LV Size 30.00 GB
Current LE 7680
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:2
--- Logical volume ---
LV Name /dev/server1/rootsnapshot
VG Name server1
LV UUID 9zR5X5-OhM5-xUI0-OolP-vLjG-pexO-nk36oz
LV Write Access read/write
LV snapshot status active destination for /dev/server1/root
LV Status available
# open 1
LV Size 9.30 GB
Current LE 2382
COW-table size 10.00 GB
COW-table LE 2560
Allocated to snapshot 0.01%
Snapshot chunk size 8.00 KB
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:5
We want to mount /dev/server1/rootsnapshot on /mnt/server1/rootsnapshot, so we have to create that directory first:
mkdir -p /mnt/server1/rootsnapshot
Then we mount our snapshot:
mount /dev/server1/rootsnapshot /mnt/server1/rootsnapshot
Then we run
ls -l /mnt/server1/rootsnapshot/
This should show all directories and files that we know from our / partition:
server1:~# ls -l /mnt/server1/rootsnapshot/
total 132
drwxr-xr-x 2 root root 4096 2007-04-10 21:02 backups
drwxr-xr-x 2 root root 4096 2007-04-10 20:35 bin
drwxr-xr-x 2 root root 4096 2007-04-10 20:25 boot
lrwxrwxrwx 1 root root 11 2007-04-10 20:25 cdrom -> media/cdrom
drwxr-xr-x 13 root root 40960 2007-04-10 20:36 dev
drwxr-xr-x 57 root root 4096 2007-04-10 21:09 etc
drwxr-xr-x 3 root root 4096 2007-04-10 20:36 home
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 initrd
lrwxrwxrwx 1 root root 28 2007-04-10 20:29 initrd.img -> boot/initrd.img-2.6.18-4-486
drwxr-xr-x 13 root root 4096 2007-04-10 20:34 lib
drwx------ 2 root root 16384 2007-04-10 20:25 lost+found
drwxr-xr-x 4 root root 4096 2007-04-10 20:25 media
drwxr-xr-x 2 root root 4096 2006-10-28 16:06 mnt
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 opt
drwxr-xr-x 2 root root 4096 2006-10-28 16:06 proc
drwxr-xr-x 3 root root 4096 2007-04-10 20:42 root
drwxr-xr-x 2 root root 4096 2007-04-10 20:36 sbin
drwxr-xr-x 2 root root 4096 2007-03-07 23:56 selinux
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 srv
drwxr-xr-x 2 root root 4096 2007-01-30 23:27 sys
drwxrwxrwt 2 root root 4096 2007-04-10 21:09 tmp
drwxr-xr-x 10 root root 4096 2007-04-10 20:26 usr
drwxr-xr-x 13 root root 4096 2007-04-10 20:26 var
lrwxrwxrwx 1 root root 25 2007-04-10 20:29 vmlinuz -> boot/vmlinuz-2.6.18-4-486
So our snapshot has successfullly been created!
Now we can create a backup of the snapshot on the /backups partition using our preferred backup solution. For example, if you like to do a file-based backup, you can do it like this:
tar -pczf /backups/root.tar.gz /mnt/server1/rootsnapshot
And if you like to do a bitwise backup (i.e. an image), you can do it like this:
dd if=/dev/server1/rootsnapshot of=/backups/root.dd
server1:~# dd if=/dev/server1/rootsnapshot of=/backups/root.dd
19513344+0 records in
19513344+0 records out
9990832128 bytes (10 GB) copied, 320.059 seconds, 31.2 MB/s
You could also use both ways to be prepared for whatever might happen to your /dev/server1/root volume. In this case, you should have two backups afterwards:
ls -l /backups/
server1:~# ls -l /backups/
total 9947076
drwx------ 2 root root 16384 2007-04-10 21:04 lost+found
-rw-r--r-- 1 root root 9990832128 2007-04-10 21:28 root.dd
-rw-r--r-- 1 root root 184994590 2007-04-10 21:18 root.tar.gz
Afterwards, we unmount and remove the snapshot to prevent it from consuming system resources:
umount /mnt/server1/rootsnapshot
lvremove /dev/server1/rootsnapshot
That's it, you've just made your first backup from an LVM snapshot.
Back Up (And Restore) LVM Partitions With LVM Snapshots
Back Up (And Restore) LVM Partitions With LVM Snapshots - Page 3
Recent comments
9 hours 49 min ago
15 hours 37 min ago
17 hours 28 min ago
19 hours 13 min ago
23 hours 3 min ago
1 day 4 hours ago
1 day 4 hours ago
1 day 9 hours ago
1 day 14 hours ago
1 day 20 hours ago