Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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":


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

share|improve this question

2 Answers 2

up vote 15 down vote accepted

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

share|improve this answer

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:


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:


...you need to add the trailing slash, otherwise, a folder called Pictures is created inside the Pictures folder that we specify as destination.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.