Backing up zfs system to external disk
jmc-freebsd2 at milibyte.co.uk
Sat Jul 26 12:17:32 UTC 2014
I've put together a script that backs up my zfs system to a zfs pool
on an external ESATA drive.
The script imports the backup pool with the -N option to avoid
mounting filesystems on top of the running system, updates the backup
pool to the latest snapshot with zfs send | zfs receive and then
exports the backup pool.
This normally works fine except in the rare cases when the system is
shut down or crashes while the backup pool is still imported. If this
happens then problems arise on the next reboot because filesystems
will be mounted from both the system and backup pools using identical
I tried creating the backup pool with the "-m none" option to avoid
this but it didn't help. It only appears to apply to datasets created
with "zfs create" - datasets resulting from "zfs receive" retain their
As a workaround I've created the following rc script which checks for
and exports the backup pool before the local filesystems are mounted
and seems to work OK. Since this isn't part of the base system I ought
to put it in /usr/local/etc/rc.d but it needs to run before /usr is
mounted so I had to put it in /etc/rc.d.
I was wondering if there was a better way of solving this problem
without breaking to the normal file system hierarchy?
8< - 8< - 8< - 8< - 8< - 8< - 8< - 8< - 8< -8< - 8< -
# BEFORE: zfs
# REQUIRE: root
echo "Checking esata backup pool"
if zpool list $check_esata_pool 1>/dev/null 2>&1
echo "Exporting $check_esata_pool"
zpool export $check_esata_pool
More information about the freebsd-questions