aboutsummaryrefslogtreecommitdiff
path: root/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'handlers')
-rw-r--r--handlers/rsync.in27
1 files changed, 24 insertions, 3 deletions
diff --git a/handlers/rsync.in b/handlers/rsync.in
index 73507c8..85e1c99 100644
--- a/handlers/rsync.in
+++ b/handlers/rsync.in
@@ -1100,6 +1100,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
@@ -1109,6 +1131,7 @@ set_rsync_options
start_mux
stop_services
mount_rw
+set_pipefail
starttime="`date +%c%n%s`"
echo "Starting backup at `echo $starttime | head -n 1`" >> $log
@@ -1121,9 +1144,6 @@ for SECTION in $include; do
set_filelist
set_dest
- # Ensure that a non-zero rsync exit status is caught by our handler
- set -o pipefail
-
info "Syncing $SECTION on $dest_path..."
debug $nice $rsync "${rsync_options[@]}" $filelist_flag $excludes $batch_option $orig $dest_path
$nice $rsync "${rsync_options[@]}" $filelist_flag $excludes $batch_option $orig $dest_path | tee -a $log
@@ -1136,6 +1156,7 @@ for SECTION in $include; do
done
+restore_pipefail
mount_ro
run_fsck
start_services