I am writing a script where I'd like to upload individual files and have the folder structure automatically generated like mkdir -p but I can't get rsync 2.6.9 (both) to cooperate.

It looks like rsync is making only one level of folders, otherwise erroring.

I'm trying to reproduce handy ncftpput -C -R -m remote-host local-path-name remote-path-name actions ( ncftp's Recursive mode; copy whole directory trees + Attempt to make the remote destination directory before copying.).


My Attempts:

rsync -av -e ssh /home/gitrepos/www/board/httpdocs/B/C/delete_snippet.processor.php user@testboard.org:/var/www/vhosts/testboard.org/httpdocs/B/C/delete_snippet.processor.php


rsync: push_dir#3 "/var/www/vhosts/testboard.org/httpdocs/B/C" failed: No such file or directory (2)

rsync -av -e ssh /home/gitrepos/www/board/httpdocs/B/C/delete_snippet.processor.php user@testboard.org:/var/www/vhosts/testboard.org/httpdocs/

works, creates httpdocs, but without the B/C structure.

rsync -advR -e ssh -v /home/gitrepos/www/board/httpdocs/B/C/delete_snippet.processor.php user@testboard.org:/var/www/vhosts/testboard.org/httpdocs/

works but recreates the entire /home/gitrepos... structure on the server.

permissions are set 777 and owned by user.

Thanks for help.


If you're using rsync 2.6.7 or later you can try the dot slash method after the httpdocs for limiting the directories. Try this:

rsync -advR -e ssh -v /home/gitrepos/www/board/httpdocs/./B/C/delete_snippet.processor.php user@testboard.org:/var/www/vhosts/testboard.org/httpdocs/
  • Hey it works! The internet version of the manual made it sound like that was 3.0+ feature and I didn't see it in my local manfile. I halfheartedly tried but wasn't sure which side it belonged on. Thank you. – thadk Oct 20 '10 at 18:42

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.