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

Fix rsync issues with quotes in remote path #1256

Closed

Conversation

FMeinicke
Copy link
Contributor

I recently noticed that my scheduled backups were failing because of a rsync error. Here's the log output:

[I] ...
[I] Take snapshot
[I] rsync --recursive --times --devices --specials --hard-links --human-readable --links --perms --executability --group --owner --rsh=ssh -o ServerAliveInterval=240 -o LogLevel=Error -o IdentityFile=/home/florian/.ssh/id_rsa -p 22 --delete --delete-excluded -v -i --out-format=BACKINTIME: %i %n%L --link-dest=../../20220516-210001-824/backup --chmod=Du+wx --exclude=... --include=... / Florian@my_server:"backups/backintime/manjaro/florian/1/new_snapshot/backup"
[I] Take snapshot (rsync: sending incremental file list)
[I] Take snapshot (rsync: rsync: mkdir "/volume1/homes/Florian/"backups/backintime/manjaro/florian/1/new_snapshot/backup"" failed: No such file or directory (2))
[E] Error: rsync: mkdir "/volume1/homes/Florian/"backups/backintime/manjaro/florian/1/new_snapshot/backup"" failed: No such file or directory (2)
[I] Take snapshot (rsync: rsync error: error in file IO (code 11) at main.c(615) [Receiver=3.0.9])
[I] Take snapshot (rsync: rsync: connection unexpectedly closed (215 bytes received so far) [sender])
[I] Take snapshot (rsync: rsync error: error in rsync protocol data stream (code 12) at io.c(228) [sender=v3.2.4])

Just for reference: The SSH server I'm backing up to is a Synology NAS.

The problem is that rsync seems unable to handle the quotes in Florian@my_server:"backups/backintime/manjaro/florian/1/new_snapshot/backup". Removing the quotes resulted in a successful backup again.

I don't know whether my local rsync or the remote rsync changed behavior in a newer version. For reference here are the rsync versions I'm using:
local

$ rsync --version
rsync  version v3.2.4  protocol version 31
Copyright (C) 1996-2022 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, symlinks, symtimes, hardlinks, hardlink-specials,
    hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, ACLs,
    xattrs, optional protect-args, iconv, prealloc, stop-at, no crtimes
Optimizations:
    SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
Checksum list:
    xxh128 xxh3 xxh64 (xxhash) md5 md4 none
Compress list:
    zstd lz4 zlibx zlib none

remote

$ rsync --version
rsync  version 3.0.9  protocol version 30
Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    no socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, no ACLs, xattrs, iconv, no symtimes

I assume the purpose of the quotes is to support paths with spaces. So, to achieve the same behavior as before there is the --protect-args option in rsync which allows using paths with spaces without having to surround them with additional quotes.

This PR adds the --protect-args flag to the rsync command and removes all explicit quotes around remote paths.
I don't know if changing the default value of the quote parameter in rsyncRemotePath is the preferred solution but it was the easiest for me to do. :D

I tested this with my setup using a remote backup path with and without spaces and it worked just as before.

Just FYI: I also found the suggestion that quoting the whole user@host:path (i.e. "Florian@my_server:backups/backintime/manjaro/florian/1/new_snapshot/backup" in my case) should work but this didn't seem to be the case here.

@buhtz
Copy link
Member

buhtz commented Aug 22, 2022

I assume this is related to #1247 .

@FMeinicke
Copy link
Contributor Author

Yep. this is related.

It seems like my solution would potentially break with rsync<3.2.4, though. I saw in #1247 that you're currently working on a backward compatible fix. Since I'm okay with using the workarounds (RSYNC_OLD_ARGS or --old-args) posted there I'm going to close this.

@FMeinicke FMeinicke closed this Aug 23, 2022
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

Successfully merging this pull request may close these issues.

2 participants