使用 rsync 进行双向同步

发布于 2024-09-03 14:47:57 字数 1827 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

从来不烧饼 2024-09-10 14:47:57

尝试 Unison:http://www.cis.upenn.edu/~bcpierce/unison/ code

语法:

unison dirA/ dirB/

Unison 询问当文件不同时要做什么,但您可以使用以下接受默认(不冲突)选项的命令来自动化该过程:

unison -auto dirA/ dirB/

< >unison -batch dirA/ dirB/ 根本不问任何问题,并写入输出有多少文件被忽略(因为它们存在冲突)。

注意:我不再使用 Unison(我使用 NextCloud,它不能解决原始用例)。但请注意,rsync 并非专为双向同步而设计,而 unison 则适用。 unison 可能有其缺陷(与任何其他软件一样)和缺陷。我很惊讶它现在似乎得到了积极的维护(上次我看的时候我想我认为它看起来已经死了),但我不确定现在的状态如何。我不需要双向文件同步器,因此可能有更好的选择。

注 2:我现在出于某些目的使用 Mutagen。它仍然没有完全涵盖问题的用例,但它确实实现了双向同步。

Try Unison: http://www.cis.upenn.edu/~bcpierce/unison/

Syntax:

unison dirA/ dirB/

Unison asks what to do when files are different, but you can automate the process by using the following which accepts default (nonconflicting) options:

unison -auto dirA/ dirB/

unison -batch dirA/ dirB/ asks no questions at all, and writes to output how many files were ignored (because they conflicted).

Note: I am no longer using Unison (I use NextCloud, which doesn't address the original use case). However, note that rsync is not designed for bidirectional sync, while unison is. unison may have its bugs (as any other piece of software) and its wrinkles. I am surprised it seems to be actively maintained now (last time I looked I think I thought it looked dead), but I'm not sure what's the state nowadays. I haven't had the need to have a two-way file synchronizer, so there may be better options, though.

Note 2: I am now currently using Mutagen for some purposes. It still doesn't cover the question's use case completely, but it does implement two-way sync.

温馨耳语 2024-09-10 14:47:57

我很惊讶还没有人提到Syncthing。多年来我一直使用它来同步我的手机、平板电脑和两台笔记本电脑。有一次,我还使用它向大约 600 公里外的家人发送 10 GB 的照片,直接从我的机器发送到他们的机器,而且速度非常快(尽管数据通过 Syncthing 的发现服务器路由以解决 NAT 问题)。我也曾尝试过 OwnCloud/NextCloud,但 Syncthing 更可靠,而且速度也更快。

I'm surprised no one has mentioned Syncthing yet. I have been using it for years to synchronize my phone, my tablet and my two laptops. One time I also used it to send 10 GB of photos to my family ~600 km away, straight from my machine to their machine, and it was incredibly fast (despite the data getting routed through Syncthing's discovery server to work around NAT issues). I also tried OwnCloud/NextCloud at some point but Syncthing has been much more reliable and, also, much faster.

夜司空 2024-09-10 14:47:57

由于最初的问题还涉及台式机和笔记本电脑以及涉及音乐文件的示例(因此他可能使用 GUI),我还要提到迄今为止最好的双向、多平台、免费和开源程序之一:< a href="http://freefilesync.sourceforge.net/" rel="nofollow noreferrer">FreeFileSync。

它基于 GUI,非常快速和直观,具有过滤和许多其他选项,包括远程连接、查看和交互式管理“冲突”(例如具有相似时间戳的文件)以及在双向传输、镜像和传输之间切换的能力。很快。

FreeFileSync 可以轻松同步同一网络上的两台计算机,也可以同步不同网络和远程网络上的两台计算机。

  • 在同一网络上:让 FreeFileSync 在一侧使用本地文件系统,在另一侧使用共享网络驱动器/路径。在 Windows 系统上,您在一台计算机上启用文件/磁盘共享并从另一台计算机访问该共享。我通过这种方式使用 FreeFileSync 来保持我的主要开发 PC 源代码与我的 2 台笔记本电脑同步。
    我还将其中一台笔记本电脑与安装了 Samba 并共享其目录之一的 Linux 服务器同步。
  • 跨网络:创建VPN,同上操作。 FreeFileSync 将看到远程磁盘,就像它在本地网络上一样。或者购买一台允许您连接 USB 磁盘并通过互联网共享的路由器。我在远程 Linux 服务器上安装了 VPN,并通过 OpenVPN Windows 客户端使用它。

Since the original question also involves a desktop and laptop and example involving music files (hence he's probably using a GUI), I'd also mention one of the best bi-directional, multi-platform, free and open source programs to date: FreeFileSync.

It's GUI based, very fast and intuitive, comes with filtering and many other options, including the ability to remote connect, to view and interactively manage "collisions" (in example, files with similar timestamps) and to switch between bidirectional transfer, mirroring and so on.

FreeFileSync can easily sync two computers on the same network and also sync two computers on different and remote networks.

  • On same network: have FreeFileSync use the local file system on one side and a shared network drive / path on the other. On Windows systems you enable file / disk sharing on one computer and access that share from the other. I use FreeFileSync this way to keep my main development PC source code synced with my 2 laptops.
    I have also synced one of these laptops with a Linux server with Samba installed and sharing one of its directories.
  • Across networks: create a VPN and do the same as above. FreeFileSync will see the remote disk as it was on the local network. Or buy one router that allows you to connect a USB disk to it and share over the internet. I have installed a VPN on a remote Linux server and used it through the OpenVPN Windows client.
就是爱搞怪 2024-09-10 14:47:57

您还可以尝试 bitpocket:https://github.com/sickill/bitpocket

You could also try bitpocket: https://github.com/sickill/bitpocket

简单气质女生网名 2024-09-10 14:47:57

试试这个,

get-music:
 rsync -avzru --delete-excluded server:/media/10001/music/ /media/Incoming/music/

put-music:
 rsync -avzru --delete-excluded /media/Incoming/music/ server:/media/10001/music/

sync-music: get-music put-music

我刚刚测试了这个,它对我有用。我正在 Windows7(使用安装了 rsync 软件包的 cygwin)和 FreeNAS 文件服务器(FreeNAS 在预安装了 rsync 软件包的 FreeBSD 上运行)之间进行 2 路同步。

Try this,

get-music:
 rsync -avzru --delete-excluded server:/media/10001/music/ /media/Incoming/music/

put-music:
 rsync -avzru --delete-excluded /media/Incoming/music/ server:/media/10001/music/

sync-music: get-music put-music

I just test this and it worked for me. I'm doing a 2-way sync between Windows7 (using cygwin with the rsync package installed) and FreeNAS fileserver (FreeNAS runs on FreeBSD with rsync package pre-installed).

疯狂的代价 2024-09-10 14:47:57

您可以使用 Osync: http://www.netpower.fr/osync ,它是基于 rsync 的智能删除传播。它还具有多种选项,例如恢复暂停的执行、软删除和时间控制。

You might use Osync: http://www.netpower.fr/osync , which is rsync based with intelligent deletion propagation. it has also multiple options like resuming a halted execution, soft deletion, and time control.

烂柯人 2024-09-10 14:47:57

您可以尝试 csync,它是 owncloud

You could try csync, it is the sync engine under the hood of owncloud.

寄居者 2024-09-10 14:47:57

我现在使用 SparkleShare https://www.sparkleshare.org/

适用于 Mac、Linux 和 Windows。

I'm now using SparkleShare https://www.sparkleshare.org/

works on mac, linux and windows.

夜无邪 2024-09-10 14:47:57

Rclone 就是您正在寻找的。 Rclone(“云存储的 rsync”)是一个命令行程序,用于在不同的云存储提供商(包括本地文件系统)之间同步文件和目录。 Rclone 以前称为 Swiftsync,自 2013 年起推出。

Rclone is what you are looking for. Rclone ("rsync for cloud storage") is a command line program to sync files and directories to and from different cloud storage providers including local filesystems. Rclone was previously known as Swiftsync and has been available since 2013.

往昔成烟 2024-09-10 14:47:57

我不确定它是否适用于两次同步,但要使 --delete 工作,您还需要添加 --recursive 参数。

I'm not sure whether it works with two syncing but for the --delete to work you also need to add the --recursive parameter as well.

樱花落人离去 2024-09-10 14:47:57

我构建了一个轻量级、易于使用且易于配置的守护进程,名为 livesync,请在 查看它https://github.com/brauliobo/ruby-livesync

它依赖 pyinotify 来观看并从远程同步到本地,重用相同的持久 ssh 连接

I've built a lightweight, simple-to-use and easy to configure daemon called livesync, check it out at https://github.com/brauliobo/ruby-livesync

It relies on pyinotify to watch and sync from remote to local, reusing the same persist ssh connection

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文