2 Aug 2012 23:21
Shellscript escaping problem
Martijn Rijkeboer <martijn <at> bunix.org>
2012-08-02 21:21:01 GMT
2012-08-02 21:21:01 GMT
Hi,
I'm using the script below and it keeps giving me the following error:
Unexpected remote arg: backup <at> fqdn:/data/dir/
rsync error: syntax or usage error (code 1) at main.c(1214) [sender=3.0.9]
It looks like something is going wrong with my escaping, because when I
remove the --rsync-path line everything works fine. It also works fine
if I echo the last line of the script and copy and paste it in my shell
(KSH). I've tried all kinds of different escaping and nothing seems to
work. Any ideas on what I'm doing wrong?
Kind regards,
Martijn Rijkeboer
------------------------
#!/bin/sh
DATADIR="/data"
TODAY=`/bin/date +%Y%m%d`
RSYNC_CMD="/usr/local/bin/rsync -v -n \
--rsync-path='rsync sudo' \
--rsh=ssh \
--archive --one-file-system --compress --hard-links --numeric-ids \
--human-readable --delete-after --backup --backup-dir=deleted/$TODAY \
--exclude=deleted"
(Continue reading)
if you need it to be reusable, I'd suggest making it a function or so:
...
synchronize() {
/usr/local/bin/rsync -v -n \
--rsync-path='/usr/bin/sudo /usr/local/bin/rsync' \
--archive --one-file-system --compress --hard-links \
--numeric-ids --human-readable --delete-after \
--backup --backup-dir=deleted/$TODAY \
--exclude=deleted \
RSS Feed