Performing Snapshot Based Backups on FreeBSD

Although the solution described below works, there are serious drawbacks since the snapshot generation takes enormously long time and renders the system unusable. Better approach of using a new ZFS file system is recommended. Nevertheless, FreeBSD cannot yet be installed on the ZFS directly and therefore it is a bit tricky to set up the system.

First create a snapshot on UFS file system:

# mount -u -o snapshot /var/snapshot/snap /var

The snapshot file must be located on the same partition that is being snapshotted.

In order to perform backup the snapshot must be loop-mounted:

# mdconfig -a -t vnode -f /var/snapshot/snap -u 4
# mount -r /dev/md4 /mnt

When backup is done, unmount the snapshot, delete the MD-device and remove the snapshot:

# umount /mnt
# mdconfig -d -u 4
# rm /var/snapshot/snap