Remove the quotes in your rsync call. Quotes break rsync's ability to parse the individual arguments.
For example:
Should expand to
and
two separate arguments inside rsync. But by putting quotes around it you're forcing rsync to treat it as ONE argument, which is invalid.
If you want to play around with how arguments will expand given your quoting style, put this into a new code:
Code:
#!/bin/bash
for i in "$@"; do
echo $i
done
and then replace "rsync" in your call with this new script name and see what it prints
For example
Code:
$ ./script a b c
a
b
c
$ ./script "a b" c
a b
c
And using your call:
Code:
$ HOST=host
$ NAME=name
$ TODAY=today
$ LAST=last
$ SRC="$MNT"
$ LNK="/backup/$HOST/$NAME/$LAST/"
$ TRG="/backup/$HOST/$NAME/$TODAY/"
$ OPT1="-aAXv --delete --progress --link-dest=$LNK"
$ ./script "$OPT1 $SRC $TRG"
-aAXv --delete --progress --link-dest=/backup/host/name/last/ /backup/host/name/today/
when it SHOULD look like
Code:
$./script $OPT1 $SRC $TRG
-aAXv
--delete
--progress
--link-dest=/backup/host/name/last/
/backup/host/name/today/
You should inject some spaces into your host, name, today, last, and src variables to make sure everything is handled properly.
Also, variable names in all caps are generally reserved for environment variables rather than local script variables. It improves readability later on.