Backing up zfs system to external disk

CyberLeo Kitsana cyberleo at cyberleo.net
Sat Jul 26 21:36:53 UTC 2014


On 07/26/2014 07:14 AM, Mike Clarke wrote:
> 
> 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 
> mountpoints.
> 
> 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 
> original mountpoints.
> 
> 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?

Set canmount=off or noauto on the backup datasets. Beware that this
property is not inherited, so you must explicitly set it on every
dataset for which you wish to avoid auto-mounting.

-- 
Fuzzy love,
-CyberLeo
Technical Administrator
CyberLeo.Net Webhosting
http://www.CyberLeo.Net
<CyberLeo at CyberLeo.Net>

Furry Peace! - http://www.fur.com/peace/


More information about the freebsd-questions mailing list