Ssh – rsync unexpected remote arg: user@server:/path

rsyncssh

I'm trying to use this rsync backup script on my server. However, I get the following error (when the script tries to execute the following command:

$ rsync -ar --delete -vvv -e 'ssh -i /root/.ssh/id_rsa_LAV.pub' --exclude='.*' looise-av.be@ssh.looise-av.be:/www/wp /mnt/hdd/LAV-backups/wp.0
Unexpected remote arg: looise-av.be@ssh.looise-av.be:/www/wp
rsync error: syntax or usage error (code 1) at main.c(1348) [sender=3.1.1]
[sender] _exit_cleanup(code=1, file=main.c, line=1348): about to call exit(1)

Strangely enough, everything works fine if I copy-paste* that into my terminal and press enter. It only goes wrong when it's executed by the script.

What's wrong here? How can I fix this?

*copy-paste = echo the line in the script, and then copy paste it after running the script once.

Best Answer

What is the scripting language? Is it just a bash shell script? Keep an eye out for special characters in the scripting method of choice. It's possible something in your command is getting replaced.

If bash, store the whole string in a var and echo it out, is it the same? If its modified some special characters are seen and it gets modified. This gets me when running an escaped awk command in a bash script.

Unrelated, but rsync is best for maintaining data clones of source and dest directory. Probably not the best for backups in time. I'd recommend the following to maintain a clone that preserves properties and permissions, etc. rsync –avz –delete-after

-a (archive, preserve permissions of data) -v (verbose) -z (compress) -delete-after (waits until full file list is known prior to deleting data in dest directory that no longer exists in source)

Related Topic