Creating intermediate directories?

Wayne Davison wayned at samba.org
Thu Jan 27 09:04:56 GMT 2005


On Wed, Jan 26, 2005 at 10:28:46AM -0800, Jon Drukman wrote:
> And I want it to arrive on the remote machine at:
> 
> /other/foreign/directory/file.zip
> 
> But only /other exists, is there any way to have rsync create the 
> intermediate directories?

Solution #1 (uses -R):

    cd /scratch-dir
    mkdir foreign
    ln -s /some/local/path foreign/directory
    rsync -avR --no-implied-dirs foreign/directory/file.zip host:/other
    rm -rf foreign

That causes rsync to duplicate the relative path dirs as dirs instead of
making the last one a symlink.

Solution #2 (sends the dirs separately):

    cd /scratch-dir
    mkdir -p foreign/directory
    rsync -av foreign host:/other
    rsync -av /some/local/path/file.zip host:/other/foreign/directory
    rm -rf foreign

Solution #3 (makes the dirs without using rsync):

    ssh host mkdir -p /other/foreign/directory
    rsync -av /some/local/path/file.zip host:/other/foreign/directory

..wayne..


More information about the rsync mailing list