我非常喜欢 Keep Remote Directory Up-to-date Winscp 中的功能.不幸的是,我找不到在 OS X 或 Linux 中使用这么简单的东西。我知道理论上可以使用 changedfiles 来完成同样的事情或 rsync ,但我一直发现这两种工具的教程都缺乏和/或矛盾。
我基本上只需要一个在 OSX 或 Linux 中工作的工具,并在我对本地目录进行更改时保持远程目录与本地目录同步(镜像)。
更新
查看解决方案,我发现有一对解决了保持远程目录与本地目录同步的一般问题手动。我知道我可以设置一个 cron 任务来每分钟运行一次 rsync,这应该非常接近实时。
这不是我正在寻找的确切解决方案,因为 winscp 会这样做以及更多:它检测目录中的文件更改(当我处理它们时),然后自动将更改推送到远程服务器。我知道这不是最好的解决方案(没有代码存储库),但它允许我在开发时非常快速地在服务器上测试代码。有谁知道如何将 rsync 与任何其他命令结合来获得此功能?
最佳答案
lsyncd似乎是完美的解决方案。它结合了 inotify(监视目录树中文件更改的内核内置函数)和 rsync(跨平台文件同步工具)。
lsyncd -rsyncssh /home remotehost.org backup-home/
引用自 github:
Lsyncd watches a local directory trees event monitor interface (inotify or fsevents). It aggregates and combines events for a few seconds and then spawns one (or more) process(es) to synchronize the changes. By default this is rsync. Lsyncd is thus a light-weight live mirror solution that is comparatively easy to install not requiring new filesystems or blockdevices and does not hamper local filesystem performance.
https://stackoverflow.com/questions/9279/