From: Alan J. Pippin Date: Mon, 24 Aug 2020 00:21:42 +0000 (-0600) Subject: Return non-zero exit code if any command in pipe fails X-Git-Url: http://git.pippins.net/embedvideo/.git/static/images/%7Blink_ppi%7D?a=commitdiff_plain;h=a44c3f17def4addd4be08f31b934afa9c4ce0a8d;p=zfs-ubuntu%2F.git Return non-zero exit code if any command in pipe fails Change-Id: I463e7afc7ee01a352558194eabbac67c9446b106 --- diff --git a/zfs-replicate b/zfs-replicate index 02f9924..7f205e2 100755 --- a/zfs-replicate +++ b/zfs-replicate @@ -18,6 +18,9 @@ remote=$1 remote_fs=$2 remote_pool=${2%%/*} +# return non-zero exit code if any command in the pipe fails +set -o pipefail + # get the backup pool from the command line or the config file if not specified if [[ -n $3 ]]; then backup_pool=$3 @@ -264,6 +267,7 @@ fi # don't check the return codes here because these may not exist, and that is ok $zfs destroy ${backup_pool}/${previous_backup_marker} > /dev/null 2>&1 $ssh $remote $zfs destroy ${previous_backup_marker} > /dev/null 2>&1 +sleep 1 # Rename the current backup marker to be the previous backup marker $zfs rename ${backup_pool}/${current_backup_marker} ${backup_pool}/${previous_backup_marker} diff --git a/zfs-restore b/zfs-restore index 4014ff7..d5ca2e6 100755 --- a/zfs-restore +++ b/zfs-restore @@ -16,6 +16,9 @@ dst_pool=$3 dst_fs=$4 dst_hostname=$5 +# return non-zero exit code if any command in the pipe fails +set -o pipefail + if [[ -z "$SCRIPT_UNDER_TEST" ]]; then exec >> $logdir/zfs-restore.log 2>&1 fi