Use expect_empty_remote_list flag when checking if remote list should be empty or not
[zfs-ubuntu/.git] / zfs-replicate
index e6e6dd550d0fea239076a44309825c82ad568b19..60a23457d583c8555a0df88384cd44e29d0277cf 100755 (executable)
@@ -158,8 +158,10 @@ $ssh $remote \
     $zfs list -H -t snapshot |
     grep ^${remote_fs}@ |
     awk '{print$1}' > $remote_list
-if [ $? != 0 ]; then
-  fatal_and_exit "-E- remote $zfs list on $hostname command failed" $mailto
+if [[ $? != 0 ]] && [[ $expect_empty_remote_list == 0 ]]; then
+  echo "-W- Unable to find $remote_fs on the remote host $hostname. Unable to proceed since the"
+  echo "    expect_empty_remote_list option has not been set to allow this, skipping replicate operation."
+  fatal_and_exit "-E- remote $zfs list on $hostname for $remote_fs command failed" $mailto
 fi
 
 # List the snapshots on the local machine.