I am running this command:

rsync -zavrR --delete --links --stats --rsh="ssh -p 2222 -l user" www.example.com:/home/user/public_html/ /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 example.com 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.


Try this:

rsync -zavr --delete --links --stats --rsh="ssh -p 2222 -l user" www.example.com:/home/user/public_html/ /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)

  • 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 cyberciti.biz/tips/…. – Nathaniel Dec 12 '13 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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