scripting rsync ssh port issue
Paul Slootman
paul+rsync at wurtel.net
Fri Apr 4 15:50:53 GMT 2008
On Fri 04 Apr 2008, Sterling Windmill wrote:
> I am modifying a bash script of mine to issue an rsync to a remote host with a non-standard ssh port.
>
> Unfortunately, no combination of "bashisms" seems to make it work properly.
>
> Code snippet:
>
> ...
>
> RSYNC_OPTIONS="-aH --delete --numeric-ids -e \'ssh -p 2292\'"
> RSYNC="ionice -c3 rsync $RSYNC_OPTIONS"
Nested quotations usually do something else than you'd expect...
> $SOURCE=/some/dir
> $DEST=root at 10.2.10.1:/some/dir
Are you sure about the above lines? I'd lose the $ in the 1st column.
(Or was that your shell prompt...)
> $RSYNC --progress "$SOURCE" "$DST"
That will probably present the arguments to rsync differently then
expected. A simple test:
$ cat showargs.sh
#!/bin/sh
for i; do
echo "ARG: $i"
done
$ RSYNC_OPTIONS="-aH --delete --numeric-ids -e \'ssh -p 2292\'"
$ RSYNC="ionice -c3 rsync $RSYNC_OPTIONS"
$ SOURCE=/some/dir
$ DEST=root at 10.2.10.1:/some/dir
$ ./showargs.sh $RSYNC --progress "$SOURCE" "$DST"
ARG: ionice
ARG: -c3
ARG: rsync
ARG: -aH
ARG: --delete
ARG: --numeric-ids
ARG: -e
ARG: \'ssh
ARG: -p
ARG: 2292\'
ARG: --progress
ARG: /some/dir
ARG:
(With $DEST instead of $DST it shows root at 10.2.10.1:/some/dir as the
last ARG, instead of the empty one now.)
I wish you much pleasure in trying to solve this in this way :-)
I'd create a ssh-2292 commmand that looks like:
#!/bin/sh
exec /usr/bin/ssh -p 2292 "$@"
and pass that to the -e option.
Alternatively you could create an entry for that host in ~/.ssh/config
and put the port in there.
Paul Slootman
More information about the rsync
mailing list