rsync - create all missing parent directories?

前端 未结 7 1506
一个人的身影
一个人的身影 2020-12-29 01:32

I\'m looking for an rsync-like program which will create any missing parent directories on the remote side.

For example, if I have /top/a/b/c/d

7条回答
  •  旧巷少年郎
    2020-12-29 01:48

    I was looking for a better solution, but mine seems to be better suited when you have too many sub-directories to create them manually.

    Simply use cp as an intermediate step with the --parents option

    cp --parents /your/path/sub/dir/ /tmp/localcopy
    rsync [options] /tmp/localcopy/* remote:/destination/path/
    

    cp --parents will create the structure for you.

    You can call it from any subfolder if you want only one subset of the parent folders to be copied.

提交回复
热议问题