ssh - bash: rsync with options as variable -


i writing bash script, in part rsync files on ssh. unfortunately facing problem keeping rsync options variable. please take below:

    # variables     directory="/etc"     backupdirectory="/backup"     incrementalbackup="/incremental"     options="-a -e 'ssh -p 10022' -b --backup-dir=$incrementalbackup --delete"     # rsync     rsync $options user@server:$directory $backupdirectory 

unfortunately above script fails rsync error:

    unexpected remote arg: user@server:/etc     rsync error: syntax or usage error (code 1) @ main.c(1201) [sender=3.0.6] 

what saw during script debugging fact, ssh options ('ssh -p 10022') treated rsync options. question how pass correctly additional ssh settings rsync? in advance tip.

use eval. try:

eval rsync $options user@server:$directory $backupdirectory 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -