diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-12-26 21:16:58 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-12-26 21:16:58 -0200 |
commit | 5dba68ca20097b6ce8e2b6e72565e81f60855ba3 (patch) | |
tree | e1c095722a741f1ed66055ec935967b0cc1b15ce /files | |
parent | 3acc0743e3bd61869aaeba861ad25efdaf19b6e9 (diff) | |
download | puppet-backup-5dba68ca20097b6ce8e2b6e72565e81f60855ba3.tar.gz puppet-backup-5dba68ca20097b6ce8e2b6e72565e81f60855ba3.tar.bz2 |
Managing rsync handler again
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 |