From 12f7666a2f38658f418e33db9158d332545546b2 Mon Sep 17 00:00:00 2001 From: Kevin McCormick Date: Mon, 12 Sep 2016 11:28:48 -0700 Subject: [PATCH] fail early if destination fs doesn't exist zfs receive will fail, but the source snapshot has already been created, and the rotation/cleanup of old snapshots will be triggered --- backup-zfs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backup-zfs b/backup-zfs index 8c204e7..7898dc9 100755 --- a/backup-zfs +++ b/backup-zfs @@ -109,6 +109,11 @@ destfs="${dest#*:}" # get the last src component srcbase="${srcfs##*/}" +# ensure the destination fs exists before proceeding +if [[ $(ZFS "$desthost" list -H -o name "$destfs" 2>/dev/null) != $destfs ]] ; then + die 1 "destination fs '$destfs' doesn't exist" +fi + ### ### create new snapshot on src ###