Rsync gives error but only when called via bash script
I have been working on a backup script that uses rsync to do an incremental backup.
I have tested the following rsync command manually, and it runs and completes a backup without error: 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:
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 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/' 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. Code:
mkdir -p "/backup/$HOST/$NAME/$TODAY" |
Remove the quotes in your rsync call. Quotes break rsync's ability to parse the individual arguments.
For example: Code:
-aAXv --delete Code:
-aAXv Code:
--delete 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 example Code:
$ ./script a b c Code:
$ HOST=host Code:
$./script $OPT1 $SRC $TRG Also, variable names in all caps are generally reserved for environment variables rather than local script variables. It improves readability later on. |
Quote:
Code:
rsync $OPT1 "$SRC" "$TRG" > /var/log/backup/backup.rsync.log 2>&1 Code:
rsync $OPT1 --link-dest="$LNK" "$SRC" "$TRG" > /var/log/backup/backup.rsync.log 2>&1 |
Essentially these replies were correct, so thank you! I ended up putting all the arguments in an array and then calling the array.
Here is the modified code: Code:
mkdir -p "/backup/$HOST/$NAME/$TODAY" |
All times are GMT -5. The time now is 08:28 PM. |