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

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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)

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

Your Answer

 
discard

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.