From: Alan J. Pippin <alan@pippins.net>
Date: Wed, 22 Sep 2021 23:31:24 +0000 (-0600)
Subject: Use expect_empty_remote_list flag when checking if remote list should be empty or not
X-Git-Url: http://git.pippins.net/%7Beqpres_ppi_link%7D?a=commitdiff_plain;h=0b70bfc0d86add94bad09cd7f5ef78e3fed92daf;p=zfs-ubuntu%2F.git

Use expect_empty_remote_list flag when checking if remote list should be empty or not

Change-Id: I3d7820c19f4549163d946668f2c3c99a3d5f79fe
---

diff --git a/zfs-replicate b/zfs-replicate
index e6e6dd5..60a2345 100755
--- a/zfs-replicate
+++ b/zfs-replicate
@@ -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.