Directory Sync with a Subdirectory to Ignore

2019-08-29 07:11发布

I need to do a directory sync e.g. from /dir-a/ to /dir-b/ (always in this direction). However, there are two requirements:

  1. There is a particular subdirectory /dir-a/.dont-copy/ (yes, started with a .) that I should ignore. That is, /dir-a/.dont-copy/ should always stay in /dir-a/, never move.
  2. Files / directories in /dir-b/ that don't exist in /dir-a/ should be deleted.

How would I do this using command-line tools (ideally, on Mac OSX)? Thanks beforehand for your help!

1条回答
疯言疯语
2楼-- · 2019-08-29 07:57

try:

$ rsync -avz --exclude=.dont-copy --delete dir-a/ dir-b

Note the trailing slash on dir-a. If you omit that, you will get dir-b/dir-a.

查看更多
登录 后发表回答