找回密码
 立即注册
搜索
查看: 410|回复: 0

Syncthing 一款分布式 P2P 文件同步工具

[复制链接]

266

主题

0

回帖

1119

积分

管理员

积分
1119
发表于 2023-12-26 00:08:07 | 显示全部楼层 |阅读模式

Syncthing 是一款开源的免费文件实时同步工具,它采用了 P2P 分布式技术,无需中心服务器即可让多台设备(跨平台支持 Linux、Windows、macOS、iOS、Android 等系统)互相实时同步文件,而且它还提供了文件版本控制、单双向同步等实用功能。

官网:https://syncthing.net

在 Ubuntu 上安装

添加官方源(这里的程序版本要比 ubuntu 的源更新的及时):

sudo apt install curl apt-transport-https
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
echo "deb https://apt.syncthing.net/ syncthing release" > /etc/apt/sources.list.d/syncthing.list

安装:

apt update
apt install syncthing

创建一个不能登录系统的普通用户(要有 home 目录来存放 syncthing 配置文件):

adduser --shell /sbin/nologin --disabled-login syncthing

启动服务:

systemctl enable syncthing@syncthing # @ 后的是刚才创建的用户名

systemctl start syncthing@syncthing

systemctl status syncthing@syncthing

配置文件的路径是:/home/syncthing/.config/syncthing/config.xml

将配置文件中的 127.0.0.1:8384 改为 0.0.0.0:8384,否则只有在本机才能访问。

重启服务使配置生效:

systemctl restart syncthing@syncthing

浏览器访问 IP:8384 完成后续的管理账户名、密码设置及其他配置。

在 Windows 上安装

Windows GUI 版可以选择 SyncTrayzor,下载地址:https://github.com/canton7/SyncTrayzor
其实就是 syncthing 加了一个浏览器外壳,好处是可以最小化到托盘。

应用场景

用法千变万化,这里举一个我的用法作为例子。Ubuntu 服务器做备份服务端,只接收数据,不发送(不会直接在备份服务端做任何文件更改);Windows 笔记本作为备份客户端,只发送数据到服务端,不从服务器接收数据。这里所谓的服务端与客户端是应用概念上,实际上 syncthing 是点对点传输的,没有服务器。

Windows 端配置


选中要共享到的设备,不要填密码(非信任设备时才用的)。


客户端不做版本控制。


选择只发送。

此外一些不需要同步到服务端的文件可以通过忽略规则定义,比如 /新建文件夹/abc 表示忽略相对根目录下的新建文件夹中的 abc 子目录。

Ubuntu 端配置

如果已经添加了对端设备(添加设备 ID 后等会儿会自动建立连接)这时会收到共享请求:


syncthing 提供了几种版本控制方法,这个根据需要来就行了。我在服务端做备份,希望客户端的删除和修改记录保留下来,并且自动删除老的文件,所以这里选用了 Staggered File Versioning

With “Staggered File Versioning” files are also moved to a different folder when replaced or deleted on a remote device (just like “Simple File Versioning”), however, versions are automatically deleted if they are older than the maximum age or exceed the number of files allowed in an interval.

With this versioning method it’s possible to specify where the versions are stored, with the default being the .stversions folder inside the normal folder path. If you set a custom version path, please ensure that it’s on the same partition or filesystem as the regular folder path, as moving files there may otherwise fail. You can use an absolute path (this is recommended) or a relative path. Relative paths are interpreted relative to Syncthing’s current or startup directory.


这里选只接收。

好了,就介绍到这里,自己体验一下吧😀


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|棱讯科技 ( 粤ICP备2024228160号-2|粤公网安备44030002003510号 )

GMT+8, 2024-7-27 23:33 , Processed in 0.015236 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表