I have a two disk server where root is on a mirrored LVM volume, while /boot and /boot/efi are RAID1 partitions.
I want to fully backup my server, so that when a disaster happens (both disks fail, or the entire server is gone) I can recover quickly with the least downtime. Let us assume that during the recovery we have a new server available with exactly the same specs and two new fresh disks with the same "geometry", i.e. the same total size and sector size.
What I'm planning to do is the following:
- Backup the partition table of both disks with
sfdisk -d /dev/XXX > partXXX.bak
, so that I can restore it later on the new server withsfdisk /dev/XXX < partXXX.bak
. - Backup LVM metadata using
vgcfgbackup
, so that I can restore it later usingvgcfgrestore
. - Backup the actual data in the LVM volume using a snapshot and
rsync
or some other backup tool.
Now, I don't have bullet-proof solution for the /boot
and /boot/efi
partitions. This is what I came up with:
- Use
dd
to create images of the entire partitions on both disks. - Possibly compress them using
gzip
. - In case of recovery restore entire partition images on both disks using
dd
(after restoring the partition tables).
After the procedure is completed it should be possible to simply reboot the system and it should work as it did before the disaster, because the contents of the restored disks are byte-to-byte identical (complete with bootloader, superblocks, etc).
My issues with dd
are following:
- Possible data inconsistencies due to taking an image of a live filesystem. I don't expect these partitions to be often actively written to, but to limit the risks I plan to execute
sync
and then take an image, and repeat the process one more time. If both images are identical it seems safe to assume no writes happened during the first image creation. - It seems excessive to image the entire partition including the free space. While compressing should help here, and the partitions are not large (
1GiB
and200MiB
), still the approach with LVM seems smarter.
My question is the following: is there an mdadm
equivalent of vgcfgbackup
and vgcfgrestore
which could be used to reliably backup non-file metadata such as superblocks and bootloaders, so that during recovery they can be restored and that it only remains to mount the md
and rsync
data in?
Also am I perhaps missing something in my disaster recovery plan?