RSync:如何双向同步? [英] RSync: How do I synchronize in both directions?
问题描述
我想使用rsync在两个方向上同步两个目录.
I want to use rsync to synchronize two directories in both directions.
我指的是经典意义上的同步
(不是在rsync手册中的含义):
我想在两个方向上更新目录 ,
取决于其中哪个是较新.
I refer to synchronization in classical sense
(not how it is meant in rsync manuals):
I want to update the directories in both directions,
depending on which of them is newer.
这可以通过rsync (在Linux方式中更可取)完成吗?
如果没有,还有什么其他解决方案?
Can this be done by rsync (preferable in a Linux-way)?
If not, what other solutions exist?
推荐答案
只需使用较新"模式(-u或--update标志)加-t(复制文件修改时间),-r( (用于递归文件夹)和-v(用于输出详细信息以查看其作用):
Just run it twice, with "newer" mode (-u or --update flag) plus -t (to copy file modified time), -r (for recursive folders), and -v (for verbose output to see what it is doing):
rsync -rtuv /path/to/dir_a/* /path/to/dir_b
rsync -rtuv /path/to/dir_b/* /path/to/dir_a
这不能处理删除操作,但是我不确定仅通过定期同步就可以很好地解决该问题.
This won't handle deletes, but I'm not sure there is a good solution to that problem with only periodic sync'ing.
这篇关于RSync:如何双向同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!