>>> RSYNC_CMD="/usr/local/bin/rsync -v -n \
>>> --rsync-path='rsync sudo' \
>>
>> This doesn't do what you think it does. The single quotes are getting
>> literally passed to rsync, they're not reinterpreted after $RSYNC_CMD
>> is interpolated.
>
> Yep. $RSYNC_CMD will be splitted by space, tab or newline by default, or
> by the contents of $IFS, if set.
>
> 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 \
> "$@"
> }
>
> synchronize backup@fqdn:$DATADIR/dir/ $DATADIR/dir
Using a function works without problems. Thanks to all who gave input.
Kind regards,
Martijn Rijkeboer