From 042746138ba0f15394db01ce99dd5b5e81002451 Mon Sep 17 00:00:00 2001 From: "Alan J. Pippin" Date: Sun, 31 Jan 2021 18:44:04 -0700 Subject: [PATCH] Added new option to expect empty remote lists when backing up to a new disk Change-Id: I77f3f0323f876adbb3e46640dc3acee9e3b43146 --- zfs-replicate | 2 +- zfs-scripts.conf.dist | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/zfs-replicate b/zfs-replicate index 7f205e2..a5a3ad9 100755 --- a/zfs-replicate +++ b/zfs-replicate @@ -170,7 +170,7 @@ $zfs list -H -t snapshot | grep ^${backup_pool}/${remote_fs}@ | grep -v ^${backup_pool}/${current_backup_marker} | awk "{gsub(/^$backup_pool./,\"\",\$1); print\$1}" > $local_list -if [ $? != 0 ]; then +if [[ $? != 0 ]] && [[ $expect_empty_remote_list == 0 ]]; then fatal_and_exit "-E- local $zfs list on $hostname command failed" $mailto fi diff --git a/zfs-scripts.conf.dist b/zfs-scripts.conf.dist index 894f783..e4f3651 100644 --- a/zfs-scripts.conf.dist +++ b/zfs-scripts.conf.dist @@ -38,6 +38,11 @@ backup_pool= # import backup pool before replication and export backup pool after replication import_export_backup_pool=0 +# expect empty remote list +# - set to 1 if backing up any new filesystems for the first time +# - set to 0 if not backing up new filesystems for the first time (to prevent dropping the entire filesystem if the remote list command fails) +expect_empty_remote_list=0 + # when this variable is set, local filesystems will be destroyed # before receiving a full streams into them from the remote source. # if it needs to do this, and this option is set to 0, it aborts. -- 2.34.1