Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors from path arguments with spaces #82

Open
jbrad3 opened this issue May 29, 2023 · 0 comments
Open

Errors from path arguments with spaces #82

jbrad3 opened this issue May 29, 2023 · 0 comments

Comments

@jbrad3
Copy link

jbrad3 commented May 29, 2023

In v1.3.2, I have found that errors are encountered from

  • remote paths with spaces
  • rsync arguments containing paths with spaces

Here is the behavior in Ubunty 20.04.6:
$ timemachine -d remotehost:/home/user/spaced\ dir /home/user/backup
2023-05-29 16:51:34 timemachine: [DEBUG] $ ssh -oStrictHostKeyChecking=no -oLogLevel=QUIET -q remotehost test -d '/home/user/spaced dir'
bash: line 0: test: /home/user/spaced: binary operator expected

$ timemachine -d /home/user/data /home/user/backup -- --exclude-from=/home/user/spaced\ dir/exclude.txt
2023-05-29 17:02:45 timemachine: [INFO] $ rsync --exclude-from=/home/user/spaced dir/exclude.txt '/home/user/data' '/home/user/backup/.inprogress'
rsync: failed to open exclude file /home/user/spaced: No such file or directory (2)
rsync error: error in file IO (code 11) at exclude.c(1496) [client=3.1.3]
2023-05-29 17:02:45 timemachine: [ERROR] timemachine Backup has failed

These changes (in two cases each) and one addition resolve these issues:
- ssh_cmd="test -d ${dir_part}"
+ ssh_cmd="test -d \"${dir_part}\""

- cmd="ssh ${SSH_ARGS} ${ssh_part} ${ssh_cmd}"
+ cmd="ssh ${SSH_ARGS} ${ssh_part} \"${ssh_cmd}\""

+# Path escape the rsync options in case there are any spaces in them
+RSYNC_OPTS=$( escape_path "${@}" )
+

- logmsg "\$ rsync $* $( escape_path "${SRC}" ) $( escape_path "${DEST}/${BACKUP_INPROGRESS}" )"
+ logmsg "\$ rsync ${RSYNC_OPTS} $( escape_path "${SRC}" ) $( escape_path "${DEST}/${BACKUP_INPROGRESS}" )"

- $* \
+ ${RSYNC_OPTS} \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant