Project

General

Profile

Bug #9806

rsync handler fails when trying to include paths with spaces

Added by abezella over 2 years ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
Category:
rsync handler
Target version:
-
Start date:
07/24/2015
Due date:
% Done:

0%

QA Check:
Ready for QA

Description

first, thank you for backupninja and such a useful set of handlers. i've been using it for years with only minor issues.

however, i am now bumping into a problem with the rsync handler when i try to set:
include = /srv/share/Videos/TV Shows
the rsync backend incorrectly splits this into attempts to backup //srv/share/Videos/TV/ and /Shows/ (debug output below). i've tried quotes and backslashes to no better effect.

please let me know if there is any additional information that would be useful.

thanks again!

% sudo backupninja --debug --test --run /etc/backup.d/99.rsync
Debug: check_perms /etc/backup.d
Debug: perms: drwxrwx---
Debug: gperm: rwx
Debug: wperm: ---
Debug: check_perms /etc/backup.d/99.rsync
Debug: perms: -rw-------
Debug: gperm: ---
Debug: wperm: ---
Info: >>>> starting action /etc/backup.d/99.rsync (because of --now)
Debug: yes
Debug: executing handler in locked section controlled by /var/lock/backupninja/_etc_backup.d_99.rsync
Info: Syncing /srv/share/Videos/TV on /srv/backups/rsync/gondolin//srv/share/Videos/TV/TV.0/...
Debug: nice -n 0 su -c /usr/bin/rsync -av --delete --recursive --dry-run --delete-excluded    //srv/share/Videos/TV/ /srv/backups/rsync/gondolin//srv/share/Videos/TV/TV.0/
X11 connection rejected because of wrong authentication.
sending incremental file list
rsync: change_dir "//srv/share/Videos/TV" failed: Not a directory (20)
created directory /srv/backups/rsync/gondolin//srv/share/Videos/TV/TV.0

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
sent 20 bytes  received 88 bytes  216.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
Warning: Rsync error 23 when trying to transfer /srv/share/Videos/TV
Info: Syncing Shows on /srv/backups/rsync/gondolin/Shows/Shows.0/...
Debug: nice -n 0 su -c /usr/bin/rsync -av --delete --recursive --dry-run --delete-excluded    /Shows/ /srv/backups/rsync/gondolin/Shows/Shows.0/
X11 connection rejected because of wrong authentication.
sending incremental file list
rsync: change_dir "/Shows" failed: No such file or directory (2)
created directory /srv/backups/rsync/gondolin/Shows/Shows.0
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]

sent 20 bytes  received 76 bytes  192.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
Warning: Rsync error 23 when trying to transfer Shows
Warning: <<<< finished action /etc/backup.d/99.rsync: WARNING
Debug: send report to root
Info: FINISHED: 1 actions run. 0 fatal. 0 error. 2 warning.

99.rsync (1.67 KB) abezella, 07/24/2015 03:48 PM

rsync-local-quote.patch View (17.1 KB) abezella, 07/27/2015 10:40 PM

History

#1 Updated by intrigeri over 2 years ago

  • Assignee changed from rhatto to abezella
  • QA Check set to Info Needed

please let me know if there is any additional information that would be useful.

Yes:

  1. the exact version of backupninja you're using (if it comes from a distribution such as Ubuntu, we need the exact origin and version of the package)
  2. can you reproduce this with current Git?

Thanks in advance!

#2 Updated by abezella over 2 years ago

oops, yeah, sorry about that.

this is on a debian jessie host. the rsync handler fails completely w/the in-repo backupninja 1.0.1-2 package. per debian bug 683731 it looks like the presumed fix for this (commit b8b8b46f) hasn't made it in yet. anyway, the above output is from current git.

i poked around in /usr/share/backupninja/rsync a bit. the initial problem appears to be around line 1160 in the `for SECTION` loop. it loops over $include directly, whereas in at least some of the other handlers $include is parsed using IFS/SAVEIFS and then munged into a command line. that's the issue reflected in the errors above. using the IFS/SAVEIFS trick around that main loop didn't seem to be the answer, since that might have a bunch of unintended consequences in the in-loop functions. instead, to workaround it i shoved the dirs into an array (same trick) and looped over the array contents. this got me over the first hump, but then i found that there are a number of places where $SECTION and its derivative variables aren't quoted which led to other (more-or-less obvious) errors (e.g., the .0 version of the "TV Shows" SECTION was truncated to "TV," the rsync cmdline err'ed w/o add'l quoting, etc.).

i started working through the shellcheck output but there's a lot of warnings... that, along with some cleverness in getting SECTION set properly (my tweak is pretty ugly) would probably get it working. i might be able to gradually work through that and post results some time down the line. (i'm looking for sed one-liners to auto-quote unquoted vars and wishing that shellcheck had some sort of "fix-it" mode...)

#3 Updated by intrigeri over 2 years ago

  • Assignee changed from abezella to rhatto
  • QA Check changed from Info Needed to Dev Needed

Thanks!

#4 Updated by abezella over 2 years ago

the attached patch gets local rsync working when there is an include line with whitespace. a lot of it is quoting to match shellcheck's recommendations and there's likely a slicker way to break the include into SECTIONs. but this is relatively low impact and it works in the cases i tested. note that this does not address the remote case (i hope to continue to poke at this).

#5 Updated by intrigeri over 1 year ago

  • QA Check changed from Dev Needed to Ready for QA

Also available in: Atom PDF