IPv4 Address:-
IPv6 Address:-
Service Provider:-
SSL Information:-
HTTP Protocol:-
Full system backups for FreeBSD systems using ZFS [05/Aug/2012]   Fix choppy audio under PulseAudio in Gnome on FreeBSD     Increase capacity of FreeBSD ZFS array by replacing disks  

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.

gpart destroy -F da1
dd if=/dev/zero of=/dev/da1 bs=1m count=128
zpool create zbackup /dev/da1
zfs set mountpoint=/backup zbackup Copy

The above will destroy any existing data on /dev/da1, and create a ZFS filesystem which is mounted at /backup.

Next we snapshot all filesystems under zroot and send them to a gzip'd file on the backup medium.  We then release the snapshot:

zfs snapshot -r zroot@backup
zfs send -Rv zroot@backup | gzip > /backup/full-system-backup.zfs.gz
zfs destroy -r zroot@backup Copy

This is all you need to do on the live system.

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 Copy

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 Copy

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 Copy

That's all there is to it.  A fully working disaster recovery solution.

  Fix choppy audio under PulseAudio in Gnome on FreeBSD     Increase capacity of FreeBSD ZFS array by replacing disks  
Copyright © 2023 Daniel Austin MBCS.
Proudly hosted using the FreeBSD operating system.
E-mail me
E-mail me
padlock icon
LOGIN ERROR#123: random error here