I'm posting with reference to
http://www.mail-archive.com/rsync@lists.samba.org/msg17343.html
(Couldn't find a way to post directly to thread).
<QUOTE>
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.
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".
<UNQUOTE>
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:
sh-3.1# ls /mnt/removable/root
ls: /mnt/removable/root: No such file or directory
sh-3.1# ls -R /root/temp/joe/
/root/temp/joe/:
dfg file1 file2
/root/temp/joe/dfg:
sh-3.1# ls -R /mnt/removable/root
ls: /mnt/removable/root: No such file or directory
sh-3.1# rsync -auvR /root/temp/joe /mnt/removable
building file list ... done
/root/
/root/temp/
/root/temp/joe/
/root/temp/joe/file1
/root/temp/joe/file2
/root/temp/joe/dfg/
sent 4674504 bytes received 88 bytes 9349184.00 bytes/sec
total size is 4673690 speedup is 1.00
sh-3.1# ls -R /mnt/removable/root
/mnt/removable/root:
temp
/mnt/removable/root/temp:
joe
/mnt/removable/root/temp/joe:
dfg file1 file2
/mnt/removable/root/temp/joe/dfg:
Amit
On 11/13/06, Amit Dor-Shifer <amitds@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". > <UNQUOTE> > > 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. Matt