How I learned LVM again
I migrated a server with primary BackupPC role to a new HW. Moving the HDD was quite simple - to minimize the downtime time I just moved the HDD to a new HW where two new drives for RAID1 were waiting to take over the data. The fun part begins when I decided to copy the BackuPC data to a new RAID1 partition. I used LVM on the old one, but I do not like another layer of the disk management because they do overlap in the functionality (LVM can do to mirroring nowadays too). The first idea was to get rid of LVM a move the data to robust mdraid only.
I started the copy 200GB of the BackupPC data via files with rsync
rsync -avxHAX --progress /var/lib/backuppc /copy
At the beginning it looked promising - 30h ETA i.e. one daily backup missing was acceptable. However after 59h of the run the rsync was still at just 180 of 200GB and started to deal with hardlink deduplication the BackupPC is using. The speed dropped down to 3GB per day. This would be a more then I could afford. The backups need to run.
Second attemp was using the dump-restore duo
dump -0 -f - /var/lib/backuppc | restore -r -f -
after few minutes:
restore: cannot write to file /tmp//rstdir1517604355: No space left on
device
DUMP: Broken pipe
DUMP: The ENTIRE dump is aborted.
seems restore is first writing some files to /tmp.. ok used
dump -0 -f - /var/lib/backuppc | restore -r -T /copy -f -
when it gets to the
DUMP: dumping (Pass IV) [regular files]
it just stays there for 12h with almost nothing copied. Aborted.
No time left I decided to get back to LVM.
pvcreate /dev/md3 vgextend vg0 /dev/md3 pvmove /dev/sdb /dev/md3 vgreduce vg0 /dev/sdb pvremove /dev/sdb
This is all you need. Withing 5h the data were moved. This is not exactly what I wanted to achieve (copy), however LVM impressed me with the ease of the process with no downtime. If you interrupt the pvmove, just start pvmove without any argument and it continues. BackupPC can run on top of it while moving.
Making the copy with files was impossible in "real" time. LVM did that like a "dd" but online.