diff options
| -rw-r--r-- | handlers/rsync.in | 24 | 
1 files changed, 24 insertions, 0 deletions
| diff --git a/handlers/rsync.in b/handlers/rsync.in index 2d00267..386255e 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -1067,6 +1067,28 @@ function end_mux {  } +function set_pipefail { + +  # Save initial pipefail status for later restoration +  if echo "$SHELLOPTS" | grep -q ":pipefail"; then +     pipefail="-o" +  else +     pipefail="+o" +  fi + +  # Ensure that a non-zero rsync exit status is caught by our handler +  set -o pipefail + +} + +function restore_pipefail { + +  if [ ! -z "$pipefail" ]; then +    set $pipefail pipefail +  fi + +} +  # the backup procedure  eval_config @@ -1088,12 +1110,14 @@ for SECTION in $include; do    info "Syncing $SECTION on $dest_path..."    debug $nice $rsync "${rsync_options[@]}" $filelist_flag "$excludes" $batch_option $orig $dest_path +  set_pipefail    $nice $rsync "${rsync_options[@]}" $filelist_flag "$excludes" $batch_option $orig $dest_path | tee -a $log    if [ "$?" != "0" ]; then      fatal "Rsync error when trying to transfer $SECTION"    fi +  restore_pipefail    update_metadata  done | 
