Rsync creates a directory with the same name inside of destination directory
Solution 1:
If you don't want another tests
directory created, the correct command would be
rsync -avzp --del -e "ssh -p myport" user@hostname:/var/www/tests/ /var/www/tests
Note the /
at the end of user@hostname:/var/www/tests/
.
Solution 2:
You need a trailing slash on the source.
Here is the correct command:
rsync -avzp --del -e "ssh -p myport" user@hostname:/var/www/tests/ /var/www/tests
More Info
Explanation of rsync and trailing slashes:
http://defindit.com/readme_files/rsync_backup.html
Rsync has two major modes of operation. The modes are dependent on the absence or presence of the trailing slash on the source directory.
Another example:
http://www.jveweb.net/en/archives/2010/11/synchronizing-folders-with-rsync.html
...you need to add the trailing slash, otherwise, a folder called Pictures is created inside the Pictures folder that we specify as destination.