以下是Debian中copidar的使用技巧,涵蓋安裝、配置及常見操作:
sudo apt update
sudo apt install copidar # 需確保倉庫支持(部分版本可能需第三方源)
sudo apt install build-essential cmake git
git clone https://github.com/Copidar/Copidar.git
cd Copidar && mkdir build && cd build
cmake .. && make && sudo make install
copidar /path/to/directory
copidar -r /source/ /destination/
copidar -r --exclude '*.tmp' --exclude 'cache/' /source/ /destination/
-v
選項copidar -r /source/ /destination/ > /var/log/copidar.log 2>&1
~/.config/copidar/config.yaml
):watch_directories:
- /path1
- /path2
event_handlers:
- command: /path/to/script.sh
events: [create, modify, delete] # 觸發事件時執行腳本
-c
參數指定配置文件運行:copidar -c /path/to/config.yaml
cron
定期運行(如每5分鐘):*/5 * * * * /usr/bin/copidar -r /source/ /destination/ >> /var/log/copidar.log 2>&1
--exclude
過濾無關內容。sudo
。/var/log/copidar.log
),排查異常。tail -f
或日志管理工具(如 logrotate
)實時監控輸出。提示:若需監控文件系統事件(如創建、修改、刪除),優先使用 -r
遞歸模式結合事件處理器;若僅需同步文件,直接使用 -r -d
選項即可。
參考來源: