如何在两个方向上同步? [英] How do I synchronize in both directions?

查看:56
本文介绍了如何在两个方向上同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 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.

这篇关于如何在两个方向上同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆