non-existing parent directories - continued
hashproduct+rsync at gmail.com
Tue Nov 14 00:30:45 GMT 2006
On 11/13/06, Amit Dor-Shifer <amitds at oversi.com> wrote:
> [Darin Perusich wrote:]
> is there a way for rsync to create non-existing parent directories when
> syncing files to a destination? something similar to 'mkdir -p
> non-existing/directory'. i'm doing 'rsync -r /path/to/source
> /path/to/non-existing/directory', and the 'non-existing/directory'
> location doesn't exist.
> [Matt McCutchen wrote:]
> Rsync will only create the top-level destination directory, not its
> parents. So just run an appropriate "mkdir -p" command before rsync.
> If this needs to happen on the remote host of a transfer over SSH,
> pass rsync something like --rsync-path="mkdir -p
> /path/to/non-existing/directory && rsync".
> Isn't the '-r' (--relative) option designed to do exactly that?
> Here's my attempt to use a/m option. It created entire directory
> structure at dest:
You mean -R, right? -R works if the path components that need to be
created in the destination also appear at the end of the source path.
Suppose we want to copy to the destination a/b/c, but only directory
"a" exists so far. If the source path is x/y/b/c, we're in luck: we
can do "rsync -R x/y/./b/c a". But if the source path is x/y/z, -R is
no good; this was the case in Darin's question.
More information about the rsync