Rsync –exclude not excluding

backupexcludersyncubuntu-12.04

I'm using rsync on an Ubuntu 12.04 LTS server with the following script to back up all of /, however, whenever I run the script (as root), the directory /backup is included, when it should be excluded:

#!/bin/sh
rsync --password-file=/etc/rsyncd.password --delete -aAXzv --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs,/home/*/Downloads/*,/backup/*,/var/spool/squid3,/opt/atlassian,var/www/\~*} /* fsbak@servername::fsbak

Why is this happening, and how can I make rsync ignore /backup?

Best Answer

Changing #!/bin/sh to #!/bin/bash in the script has fixed this issue. The curly brace expansion used in the script is a bash feature and, as such, is not available in sh.