From f7488968c0ab80b923927cc8bf6376fd28fd5022 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 15 Jun 2012 20:21:09 +0200 Subject: rsync: generate excludes command-line snippet the same way as the duplicity handler does. The latter has a robust history wrt. dealing with excludes / glob / quoting etc., let's use that instead of the shiny new sed-based way. --- handlers/rsync.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'handlers/rsync.in') diff --git a/handlers/rsync.in b/handlers/rsync.in index 386255e..c584e7f 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -275,8 +275,15 @@ function eval_config { mv=move_files fi - excludes=`echo "$exclude" | @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 { -- cgit v1.2.3 From 1b48bc44445cba33a748bb8ad2833d7e2187d1ad Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 15 Jun 2012 20:27:01 +0200 Subject: rsync: stop passing $excludes as a single argument. --- handlers/rsync.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'handlers/rsync.in') diff --git a/handlers/rsync.in b/handlers/rsync.in index c584e7f..2620c47 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -1116,7 +1116,7 @@ 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 + 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 -- cgit v1.2.3 From 29dcdbae919787978fafd41a12d48338958e92f9 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 15 Jun 2012 20:27:31 +0200 Subject: Run rsync command-line through a shell, so that single-quotes around excludes are interpreted (Closes: #677410) When --exclude 'something' is passed directly to rsync without going through a shell, rsync tries to match a file whose name contains single quotes, which is definitely not what we want it to do: exclude arguments protected with single quotes are meant to be passed to a shell. --- handlers/rsync.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'handlers/rsync.in') diff --git a/handlers/rsync.in b/handlers/rsync.in index 2620c47..f0df52f 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -1116,9 +1116,9 @@ 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 + 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 + $nice su -c "$rsync ${rsync_options[@]} --delete-excluded $filelist_flag $excludes $batch_option $orig $dest_path" | tee -a $log if [ "$?" != "0" ]; then fatal "Rsync error when trying to transfer $SECTION" -- cgit v1.2.3