Full system backups for FreeBSD systems using ZFS 49 Replies
Assuming you have created your ZFS FreeBSD system using the instructions on my site, here is how to do full system backups to an extra attached disk.
You can adjust these instructions if you need to store the backup remotely – but they are out of scope of this post.
First, in case you haven’t already… here is how to format/dev/da1 as a dedicated ZFS backup drive. You can configure the backup drive however you want (it doesn’t even need to be ZFS-based) but you will also have to adjust these instructions accordingly to restore too.
If the worst happens, and you need to restore to a new system (or a freshly formatted one)…
Firstly, follow the original instructions up to and including the line “zfs set checksum=fletcher4 zroot”.
Next, we import the backup ZFS drive and mount it – then we use ZFS receive to restore the filesystem and all its dependants:
zpool import -f zbackup zfs set mountpoint=/boot/zfs/backup zbackup zfs mount zbackup gunzip -c /boot/zfs/backup/full-system-backup.zfs.gz | zfs receive -vdF zroot
Now we need to unmount the backup drive, and mount the original root ZFS so we can re-create the cache file (the system will not boot without the correct cache file):
zpool export zbackup zfs set mountpoint=/boot/zfs/zroot zroot cd /boot/zfs zpool export zroot && zpool import zroot cp /boot/zfs/zpool.cache /boot/zfs/zroot/boot/zfs/zpool.cache zfs unmount -a zfs set mountpoint=legacy zroot reboot
This will reboot the system in its original state. If you want to re-mount your backup medium, it will need to be re-imported and mounted:
zpool import -f zbackup zfs set mountpoint=/backup zbackup
That’s all there is to it. A fully working disaster recovery solution.