Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running this command:

rsync -zavrR --delete --links --stats --rsh="ssh -p 2222 -l user" /home/user/public_html/rsynctest

Current behavior is that I get /home/user/public_html/rsynctest/home/user/public_html/. All files in public_html are copied successfully, but I get layers of directories that I don't want.

My desired behavior is that the contents of public_html from are mirrored to the folder rsynctest on the local machine (I retain /home/user/public_html instead of creating the double layered directory structure). How can I achieve this? I thought the trailing slash on the remote directory was supposed to do it, but it's not happening.

share|improve this question
up vote 2 down vote accepted

Try this:

rsync -zavr --delete --links --stats --rsh="ssh -p 2222 -l user" /home/user/public_html/rsynctest/.

Is there any reason you are including the -R option. That's what's making rsync save your relative paths (directories)

share|improve this answer
From the rsync man page: -R, --relative Use relative paths. This means that the full path names specified on the command line are sent to the server rather than just the last parts of the filenames. – Atari911 Dec 12 '13 at 23:32
Aha! I thought I had reviewed all the options, clearly not. I am adapting from a NixCraft article…. – Nathaniel Dec 12 '13 at 23:51

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.