在Linux环境下,双向文件同步需求可以通过多种工具实现,以下是常见的解决方案分类及推荐:
sudo apt install unison
(Debian/Ubuntu)bash
unison /path/local ssh://user@remote//path/remote
sudo apt install lsyncd
lua
sync {
default.rsync,
source = "/local/path",
target = "user@remote:/remote/path",
rsync = { archive = true, delete = true }
}
bash
sudo apt install syncthing # Debian/Ubuntu
systemctl enable --now syncthing@user
bash
git init && git add . && git commit -m "Initial commit"
git remote add origin user@remote:/path/to/repo.git
git push -u origin master
bash
sudo snap install nextcloud
bash
rclone sync /local/path remote:path --progress
rclone sync remote:path /local/path --progress
curl https://rclone.org/install.sh | sudo bash
bash
#!/bin/bash
while inotifywait -r -e modify,create,delete /local/path; do
rsync -avz --delete /local/path user@remote:/remote/path
done
--bwlimit
(rsync)限速。根据具体需求(实时性、安全性、易用性)选择最适合的工具。