How to keep two folders automatically synchronized?

前端 未结 5 1138
醉话见心
醉话见心 2021-01-29 19:26

I would like to have a synchronized copy of one folder with all its subtree.

It should work automatically in this way: whenever I create, modify, or delete stuff from th

5条回答
  •  半阙折子戏
    2021-01-29 20:06

    You can use inotifywait (with the modify,create,delete,move flags enabled) and rsync.

    while inotifywait -r -e modify,create,delete,move /directory; do
        rsync -avz /directory /target
    done
    

    If you don't have inotifywait on your system, run sudo apt-get install inotify-tools

提交回复
热议问题