How to rsync exclude a specific directory

rsync

If I have the following directory structure:

foo/
    foo.txt
bar/
    foo/
        hum.txt

how do I exclude the top-level foo directory without excluding bar/foo? When I run:

rsync --exclude-from exclude-file ...

and the contents of exclude-file is merely:

foo

both directories are excluded.

Best Answer

OK, the answer is blindingly obvious. exclude-file should be written as:

/foo