Directory Sync with a Subdirectory to Ignore

▼魔方 西西 提交于 2019-12-12 02:45:55

问题


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:


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.



来源:https://stackoverflow.com/questions/8814457/directory-sync-with-a-subdirectory-to-ignore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!