cytopia / cytopia/linux-timemachine

Errors from path arguments with spaces

Open
#82 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
841
Forks
75
PR merge metrics
No merged PRs in 30d

Description

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} \`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.