-e escape rule

Paul Slootman paul+rsync at wurtel.net
Thu Oct 20 11:03:32 UTC 2016

On Thu 20 Oct 2016, Samuel Williams wrote:
> I'm using Ruby's Shellwords module, which generates a string from an
> array, suitable for shell evaluation.
> Ruby's implementation prefers escaping whitespace with a backslash
> rather than quotes. However, this appears to cause some kind of issue
> in Rsync when it computes argv from -e option.
> Here is an example command generated by some Ruby code:
> rsync --archive --stats -e ssh\ -l\ backup\ -i\ /etc/synco/id_rsa\ -o\
> ConnectTimeout\\\=60\ -o\ BatchMode\\\=yes --link-dest
> ../../latest/etc/ /etc/
> example.backup.server.com:/tank/backup/servers/blah/latest.snapshot/etc/

There's no reason to escape an "=" sign in the above command. Try:

rsync --archive --stats -e ssh\ -l\ backup\ -i\ /etc/synco/id_rsa\ -o\ ConnectTimeout=60\ -o\ BatchMode=yes --link-dest ../../latest/etc/ /etc/ example.backup.server.com:/tank/backup/servers/blah/latest.snapshot/etc/

Or even:

rsync --archive --stats -e ssh\ -i\ /etc/synco/id_rsa\ -o\ ConnectTimeout=60\ -o\ BatchMode=yes --link-dest ../../latest/etc/ /etc/ backup at example.backup.server.com:/tank/backup/servers/blah/latest.snapshot/etc/

I'd probably create an entry for this host in ~/.ssh/config :

Host example.backup.server.com
	User backup
	IdentityFile /etc/synco/id_rsa
	ConnectTimeout 60

and then just use:

rsync --archive --stats --link-dest ../../latest/etc/ /etc/ example.backup.server.com:/tank/backup/servers/blah/latest.snapshot/etc/

If you're dynamically doing this, you can pass a config file with -F.


More information about the rsync mailing list