title: Rsync syntax error when run from bash script
body: <p>I have been working on a backup script that uses rsync to do an incremental backup.</p>
  
  <p>I have tested the following rsync command manually, and it runs and completes a backup without error:</p>
  
  <pre><code>rsync -aAXv --delete --progress --link-dest=/backup/Uyuk/Uyuk-backup-part1/2014-02-24/ /mnt/backup/ /backup/Uyuk/Uyuk-backup-part1/2014-02-25/
  </code></pre>
  
  <p>however when I run that same command in my backup script it gives me the following error:</p>
  
  <pre><code>rsync: -aAXv --delete --progress --link-dest=/backup/Uyuk/Uyuk-backup-part1/2014-02-24/ /mnt/backup/ /backup/Uyuk/Uyuk-backup-part1/2014-02-25/: unknown option
  rsync error: syntax or usage error (code 1) at main.c(1422) [client=3.0.6]
  </code></pre>
  
  <p>I ran bash -x on my script to figure out exactly what is sent to the console and here is what was printed:</p>
  
  <pre><code>+ rsync '-aAXv --delete --progress --link-dest=/backup/Uyuk/Uyuk-backup-part1/2014-02-24/ /mnt/backup/ /backup/Uyuk/Uyuk-backup-part1/2014-02-25/'
  </code></pre>
  
  <p>Does anyone see what is wrong? I cant find anything that would cause the syntax error.</p>
  
  <p>EDIT:
  Here is the actual code I have in the script, and this is a pretty large script so yes some variables are not defined here, but you get the idea. </p>
  
  <pre><code>mkdir -p "/backup/$HOST/$NAME/$TODAY"
  #source directory
  SRC="$MNT"
  #link directory
  LNK="/backup/$HOST/$NAME/$LAST/"
  #target directory
  TRG="/backup/$HOST/$NAME/$TODAY/"
  #rsync options
  OPT1="-aAXv --delete --progress --link-dest=$LNK"
  
  #run the rsync command
  echo "rsync $OPT1 $SRC $TRG"
  rsync "$OPT1 $SRC $TRG" &gt; /var/log/backup/backup.rsync.log 2&gt;&amp;1
  </code></pre>