non-existing parent directories - continued

Amit Dor-Shifer amitds at oversi.com
Mon Nov 13 08:55:41 GMT 2006


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



More information about the rsync mailing list