rsync - create all missing parent directories?

前端 未结 7 1504
一个人的身影
一个人的身影 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:49

    According to https://unix.stackexchange.com/a/496181/5783, since rsync 2.6.7, --relative works if you use . to anchor the starting parent directory to create at the destination:

    derek@DESKTOP-2F2F59O:~/projects/rsync$ mkdir --parents top1/a/b/c/d
    derek@DESKTOP-2F2F59O:~/projects/rsync$ mkdir --parents top2/a
    derek@DESKTOP-2F2F59O:~/projects/rsync$ rsync --recursive --relative --verbose top1/a/./b/c/d top2/a/
    sending incremental file list
    b/
    b/c/
    b/c/d/
    
    sent 99 bytes  received 28 bytes  254.00 bytes/sec
    total size is 0  speedup is 0.00
    

提交回复
热议问题