From 89db8a3de3f66f30df7b9f3579909ccb959b34b8 Mon Sep 17 00:00:00 2001 From: Petteri Valkonen Date: Tue, 21 Apr 2015 12:16:39 +0300 Subject: [PATCH] Don't mount the target file system if 'canmount' is not set to 'on' By default, ZFS will try to mount the target file system associated with the received stream. If the 'canmount' property is set to any other value than 'on' (e.g. 'noauto'), mounting will fail and the service will enter maintenance state. --- zfs-backup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zfs-backup.sh b/zfs-backup.sh index 9970430..dbc32cd 100755 --- a/zfs-backup.sh +++ b/zfs-backup.sh @@ -244,6 +244,15 @@ do_backup() { return 1 fi + # Don't mount the target file system after receiving the stream associated + # with it if the 'canmount' property is not set to 'on' + if [ "$REMHOST" = "localhost" ]; then + canmount_target="$($ZFS get -H -o value canmount $TARGET)" + else + canmount_target="$(ssh -n $REMUSER@$REMHOST $REMZFS get -H -o value canmount $TARGET)" + fi + if [ "$canmount_target" != "on" ]; then RECV_OPT="$RECV_OPT -u"; fi + if [ $DEBUG ]; then echo "would run: $PFEXEC $ZFS send -R -I $snap1 $DATASET@$snap2 |" echo " $REMZFS_CMD recv $VERBOSE $RECV_OPT -F $REMPOOL"