Fixed zfs-replicate bug when a filesystem is created on the backup drive,
[zfs-ubuntu/.git] / zfs-replicate
index 9a6b82e3655d680e2f645c00cd24fe247b4bdbf4..da3df12614ab76e8090bdeb0a468675f09930eeb 100755 (executable)
@@ -49,7 +49,12 @@ if ! zpool list -H "$dstpool" >/dev/null 2>&1; then
 fi
 
 if ! zfs list -rH -t snapshot "$dstfs" 2>&1 | grep "$dstfs@" > /dev/null 2>&1; then
-  echo >&2 "-W- No snapshots detected on the destination drive for this filesystem"
+  echo >&2 "-W- No snapshots detected on the destination drive for this filesystem: $dstfs"
+  if zfs list -t filesystem | grep "$dstfs"; then
+   echo >&2 "-I- Found zfs filesystem $dstfs on the destination pool $dstpool without any snapshots"
+   echo >&2 "-I- Removing the zfs filesystem: $dstfs"
+   zfs destroy "$dstfs" 
+  fi
   nodstsnaps=1
 fi