I'm using the PHP Symfony framework's rsync application publication feature to publish an application from my development box to a ~archives/symfony directory on our production box. This invokes the following rsync command:
rsync --progress --dry-run -azC --force --delete --exclude-from=config/rsync_exclude.txt -e ssh ./ firstname.lastname@example.org:symfony/
I notice that when the ~archives/symfony directory doesn't already exist on the production box, rsync will delete all files and directories in the parent directory (in our case ~archives). Once I create the ~archives/symfony directory, rsync correctly copies ./* from the development box to ~archives/symfony, without touching anything else in ~archives on the production box.
I've been over the man page, especially the parts about a trailing slash on the source, and I believe this behavior is a bug. For instance, rsync's syntax is supposed to be somewhat analogous to rcp/scp where "scp -r . email@example.com:symfony" would copy the working directory to ~archives/symfony, without touching anything else in ~archives.
Also, the local analogy:
rsync --progress --dry-run -azC --force --delete --exclude-from=config/rsync_exclude.txt -e ssh ./ /tmp/symfony/
copies the working directory to /tmp/symfony, without touching anything else in /tmp.
The local version of rsync is: rsync version 2.6.9 protocol version 29
The remote version is: rsync version 2.6.3 protocol version 28
There was a bug in 2.6.3 where --dry-run could output extra files that weren't going to be removed during the real run. This was fixed in 2.6.4. The CVS version had a reprise of this bug, which I have just fixed.
Please be clear that when you said "rsync will delete all files and directories in the parent directory" you really meant to say that it will incorrectly report that all those items would be removed if --dry-run was not present. Rsync would not have actually removed any extraneous files with the same command without --dry-run.