Disaster recovery of proxmox on zfs

giovvv

Active Member
Aug 4, 2018
45
0
26
56
I have a single machine with proxmox on ZFS with a single pool containing a three-disk mirror. Backups aside, I would like to implement a simple disaster recovery strategy. The idea is to save the partition scheme of the disks on removeble media, and then dump the pool to LTO tape, so to be able to rebuild the whole thing from scratch if the need arises. I did it as follows, but at the end it does not work. Maybe someone has an idea of the why...

(note: this is a test run. Not a real disaster, the original data is preserved)

I have first backed up the disk partition schemes:

Code:
sgdisk --backup=partitions-backup-sda /dev/sda
sgdisk --backup=partitions-backup-sdb /dev/sdb
sgdisk --backup=partitions-backup-sdc /dev/sdc

Then created a snapshot of the zfs root pool and dumped it to tape:

Code:
datetime=$(date +%Y-%m-%dT%H:%M:%S)
snapname="rpool@tape_backup_${datetime}"
zfs snapshot -r ${snapname}
zfs send --replicate --verbose ${snapname} | mbuffer -m 4G -P 100% | dd of=/dev/nst0 bs=256k status=none
zfs destroy -r ${snapname}

I also verified that the backup stream contained no errors:

Code:
mt -f /dev/nst0 rewind
mbuffer -m 4G -P 100% -i /dev/nst0 | zstreamdump

At this point, I shat down the machine and removed the three original disks. In their place, I temporarily put a single new HD on which I installed proxmox from scratch, so to have some kind of zfs-supporting linux to perform the restore.
Then I connected two new HDs (I don't have three) of the same size as the original one, and I tried to restore as follows.

First I restored the partition scheme:

Code:
 sgdisk -l partitions-backup-sda /dev/sdb
sgdisk -l partitions-backup-sdb /dev/sdc

(the device names are different because sda is the boot disk at the moment)

I rebooted the machine and I created a brand new zpool, using the IDs of the new disks (obtained from the blkid command):

Code:
zpool create rpool mirror ata-WDC_WD40EZRZ-22GXCB0_WD-___-part3 ata-WDC_WD40EZRZ-22GXCB0_WD-___-part3
(serial numbes omitted)

Finally, I restored from tape the zfs dump:

Code:
mt -f /dev/nst0 rewind
dd if=/dev/nst0 bs=256k status=none | mbuffer -m 10G -r 100M | zfs receive -Fd rpool

Fast forward a couple of hours, and the zfs filesystems look perfectly restored. The problem is that if I remove the temporary proxmox hd and try to reboot the machine, it does not work. The machine does not boot at all: none of the restored disks is recognized as bootable media.

What am I doing wrong?

Thanks
 
Last edited:
update:
I have realized that I did not backup the boot partition. So for backup I did

Code:
dd if=/dev/sda2 of=partition-sda2
dd if=/dev/sdb2 of=partition-sdb2
dd if=/dev/sdc2 of=partition-sdc2

and to restore (from removable media)
Code:
dd if=partition-sda2 of=/dev/sdb2
dd if=partition-sdb2 of=/dev/sdc2

This way, the system boots from the restored disks, but then it stops because no rpool is recognized (although is there, in partitions #3). So I am still stuck.
 
Last edited:
I found out the missing step:

at the (initramfs) prompt, force the pool to be imported even if it was last accessed on a different machine:

Code:
zfs import -f rpool
zfs export rpool

(the final export step is probably unneccessary, but just in case...)

Shut down the machine, remove the temporary hard disk, and boot: the restore is succesful!
 
It also seems that this procedure corrupts the zfs cache files (the system works, but there is a FAILED message at boot). To rebuild it:

Code:
zpool set cachefile=/etc/zfs/zpool.cache rpool
update-initramfs -k all -u
reboot
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!