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 {
}
+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
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
# we have to keep that as we have custom changes that
# might not be merged and released in backupninja
- #file { "/usr/share/backupninja/rsync":
- # ensure => present,
- # owner => "root",
- # group => "root",
- # mode => 0644,
- # source => "puppet:///modules/backup/handlers/rsync",
- #}
+ file { "/usr/share/backupninja/rsync":
+ ensure => present,
+ owner => "root",
+ group => "root",
+ mode => 0644,
+ source => "puppet:///modules/backup/handlers/rsync",
+ }
# sync-backups script
file { "/usr/local/sbin/sync-backups":