diff options
Diffstat (limited to 'files')
-rw-r--r-- | files/handlers/rsync | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/files/handlers/rsync b/files/handlers/rsync index 6262af0..634f036 100644 --- a/files/handlers/rsync +++ b/files/handlers/rsync @@ -275,8 +275,15 @@ function eval_config { mv=move_files fi - excludes=`echo "$exclude" | /bin/sed -e "s/^/--exclude='/g" -e "s/ /' --exclude='/g" -e "s/$/'/"` - + set -o noglob + SAVEIFS=$IFS + IFS=$(echo -en "\n\b") + for i in $exclude; do + str="${i//__star__/*}" + excludes="${excludes} --exclude='$str'" + done + IFS=$SAVEIFS + set +o noglob } function rotate_short { @@ -1089,6 +1096,26 @@ function restore_pipefail { } +function check_rsync_exit_status { + + if [ -z "$1" ]; then + return + fi + + case $1 in + 0) + return + ;; + 1|2|3|4|5|6|10|11|12|13|14|21) + fatal "Rsync error $1 when trying to transfer $SECTION" + ;; + *) + warning "Rsync error $1 when trying to transfer $SECTION" + ;; + esac + +} + # the backup procedure eval_config @@ -1109,14 +1136,12 @@ for SECTION in $include; do set_dest info "Syncing $SECTION on $dest_path..." - debug $nice $rsync "${rsync_options[@]}" $filelist_flag "$excludes" $batch_option $orig $dest_path + command="$rsync ${rsync_options[@]} --delete-excluded $filelist_flag $excludes $batch_option $orig $dest_path" + debug $nice su -c "$command" 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 + $nice su -c "$command" | tee -a $log + check_rsync_exit_status $? restore_pipefail update_metadata |