以下是在Linux中使用FetchLinux進行文件同步的步驟:
安裝FetchLinux
sudo apt update && sudo apt install fetchlinux
配置同步任務
sync.conf
),指定源路徑和目標路徑:[source]
path = /本地/目錄路徑
[target]
path = user@遠程主機:/遠程/目錄路徑
可選參數:recursive
(遞歸同步)、delete
(刪除目標多余文件)、log
(記錄日志)。運行同步命令
fetchlinux sync -c /path/to/sync.conf
--reverse
參數:fetchlinux sync --reverse -c /path/to/sync.conf
監控與定時同步
tail -f /path/to/sync.log
cron
設置定時任務,例如每天凌晨2點同步:0 2 * * * /usr/bin/fetchlinux sync -c /path/to/sync.conf >> /path/to/sync.log 2>&1
注意:確保配置文件中路徑權限正確,敏感信息(如密碼)建議通過SSH密鑰或配置文件加密處理。
參考來源: