[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: backing up LVM volumes



Chris Davies wrote:
Bernard <bdebreil@teaser.fr> wrote:
On my previous systems, I used to create overall backups of partitions, using 'SystemRescueCD'. This is no longer possible ever since 2007 that I have a RAID1 mirroring system on my Debian.

You used to boot from SystemRescueCD and backup the partitions
corresponding to the (unmounted) filesystems block by block? Or you
mounted them and backed up the (mounted) filesystems?

I've never dared backing up mounted partitions, for fearing of mishaps


You can continue to do either of these that even though you've got RAID1
and LVM. Start up RAID1 and LVM, and then back up the logical partitions
(or filesystems) that result. Ignore the physical ones.


SystemRescueCD does not backup LVM volumes, or, if it does, that must
be a very new feature, and I have not found any doc on this.

TBH I'm not aware of any backup feature within SystemRescueCD, but there
are many useful tools there. I've successfully fixed up software RAID1
configurations, and it must work with LVM because most of my systems'
filesystems are based on RAID1/LVM combinations and it works for me.

SystemRescueCD only worked as an external boot system. Amongst the tools it proposes, is 'partimage', which creates images of partitions and compresses them. When I stated that 'SystemRescueCD' did not backup LVM volumes, I meant that 'partimage' lacked this capability. As far as I know, recent versions cannot do any better.
So, what should I do so as to backup my system ? I once tried 'dd', but I think I remember it took forever [...]

Without the bs argument you would have been reading the disk 512bytes
at a time. Try bs=1000k for better throughput.
I tried 'dd' again. It seems more promising, since it does backup everything. files are huge (about same size as the original partition, including empty space), but, in the end, it barely takes more than one hour for each of my 64 GB partitions. (By the way, I kind of recall having stated somewhere that my partitions were 200 GB in size, but I was wrong. I have two internal hard drives of 80 GB each). My partitions are :

/dev/sda1 and /dev/sdb1 => assembled onto a RAID 1 array as /dev/md0 (boot partition) (about half of a GB)

/dev/sda2 and /dev/sdb2 => assembled onto a RAID 1 array as /dev/md1 and also as /dev/mapper/vg00-root (about 64 GB each)

/dev/sda3 => fat32 partition, with MSWIN XP installed on it (10 GB)
I don't really know whether I would have been able to use the resulting
file to successfully restore the partitions if needed.

How do you know any of your backups work? Test them!

Sure ! Not so easy though ! To carry such test, you ought to have enough space available, unless you carry mini tests on small partitions.

This time, I think I have what I need. I purchased yet another external HD, with a capacity of 500 GB, and, after I had erased whatever it contained for use under MSWIN, I created four partitions using 'cfdisk', all Linux. Then I formated them to ext2 using 'mkfs -t ext2..' (mkfs -t ext2 /dev/sdc1, mkfs -t ext2 /dev/sdc2, .. ,mkfs -t ext2 /dev/sdc4) Next, I launched 'dd' as follows :

/mnt/sdc4/# dd if=/dev/sda1 of=sda1_04_10.img

Don't know if this was the best way to do, in any case I did just that. It only took a few minutes, since that partition is only half of a GB long. Then I attempted to restore the saved partition onto another partition of my external HD:

/mnt/sdc4/# dd if=sda1_04_10.img of=/dev/sdc2

This being done, and after unmounting/re-mounting the devices, I found that /dev/sdc2 was indeed a copy of /dev/sda1...

BUT...

I must say that my original /dev/sda1 was my 'boot' partition. As such, the RAID/mdadm programs did not create a LVM system ; it kept using the original ext3.

Once this was achieved, I carried on with another partition (sda2). This one was about 64 GB in size.

/mnt/sdc4/# dd if=/dev/sda2 of=sda2_04_10.img

Next morning (but I figured that the process only took a little more than one hour), I attempted to restore said partition into /dev/sdc4

/mnt/sdc4/# dd if=sda2_04_10.img of=/dev/sdc1

the result of restoring the partition sda2 onto the sdc1 partition of my external disk, was not the same as that obtained in restoring sda1 onto sdc2. I can't read, or even mount sdc1 :

root@new-host:/home/bd# mount /dev/sdc1 /mnt/exthd
mount: unknown filesystem type 'lvm2pv'
root@new-host:/home/bd#

So, my hard disk partition sda2 has been restored from its image, onto a lvm2pv logical partition.

Now, my question is : what can I do with this partition so as to restore something useful ? In case something crashes on my desktop, I imagine that, after replacing one or both hard disks, I would just have to partition and then use 'dd' to restore both sda1 (as ext3 RAID array) and sda2 (as LVM RAID array) and that the rest would follow automatically upon reboot ? Do you confirm this ?

But, as a matter of testing, what can I do ? Using 'mdadm', can I re-create a RAID array /dev/md1 or/and /dev/mapper/vg00-root ? How shall I do that, supposing that I have obtained two similar partitions (sda2 and sdb2 imaged and restored on two partitions of my external HD ? I attempted to manage with the 'mdadm' man pages, but this is not very obvious to me





Reply to: