Rsync creates a directory with the same name inside of destination directory

rsync

When I run this command

rsync -avzp --del -e "ssh -p myport" user@hostname:/var/www/tests /var/www/tests

files get synchronized but instead of saving files in /var/www/tests, Rsync creates one more directory "tests" inside of existing "tests":

/var/www/tests/tests

and puts files there. How to tell Rsync not to create a new directory?

Best Answer

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/.