I've discovered that any pattern specified for the --exclude option when rsyncing is treated as relative to the source destination, so:
Code:
rsync -azn -e ssh --exclude /foo/ /var/www/html/ me@mysite.com:/var/www/html
... means "exclude /var/www/html/foo/" not exclude "/foo/".
Is there any practical way around this? I have a shell script that builds up an rsync command based on arguments (e.g. "sync the entire website, sync just HTML files etc, sync a user-specified directory, sync just a single user-specified file etc.), but directories to be excluded must be absolutely specified. For example there is a list of directories I never want to sync:
/home/myuser/.ssh
/var/www/html/foo
Clearly my way of building up an rsync command by iterating through the exclude options is no good.
The only other approach I can think of is to
always use / as the source, and then have a bunch of absolute exclude options, and one single include option that specifies what to actually sync.
Thanks,
Antun