I am building a script that should duplicate the current users home directory to an arbitrarily selected directory, linking to the most recently created duplicate in the same directory, if any, using rsync.
The command is built and executed the following way:
... [ -z $LAST_SNAPSHOT ] && LINK_DEST="" || LINK_DEST="--link-dest \"$BACKUP_ROOT/$LAST_SNAPSHOT\"" ... /usr/bin/rsync $OPTS $EXCLUDES $LINK_DEST "$MASTER/" "$NEW_SNAPSHOT"
When I run the script rsync presents me with the following error:
--link-dest arg does not exist: "/home/backuptest/dest/backuptest/20180619_134044"
This would be expected if the directory actually did not exist but it does.
If I remove the quotes in the code building the
$LINK_DEST variable, yielding the following code
[ -z $LAST_SNAPSHOT ] && LINK_DEST="" || LINK_DEST="--link-dest $BACKUP_ROOT/$LAST_SNAPSHOT"
then rsync does not complain. I do wish to guard against any whitespace in the path so I really need the double qoutes though.
I fail to grok where the error lies. Is it with how i call rsync or do I misunderstand the shell (bash) in some way?