I usually write code or blog articles during work and leisure time. Sometimes, I need to synchronize these things when I'm slacking off. Previously, I used git repositories to synchronize when I completed a part, but it wasn't very suitable when I was halfway through. Using a storage device was also troublesome, so I needed software that could synchronize my work content between multiple devices.
I mainly write front-end code, and the biggest problem is the npm dependency issue. The size of node_modules is really terrifying, so it is also important to be able to filter custom content.
Using cloud storage#
Before Syncthing, I tried using cloud storage such as Baidu Cloud and Onedrive to synchronize files, but they were either too expensive or unable to filter out things I didn't want to synchronize. In general, they didn't meet my requirements.
Although I subscribed to Baidu Cloud Drive svip for a year, it's actually not bad for downloading things
Syncthing#
Syncthing is a lightweight, open-source, peer-to-peer file synchronization software that does not require a third-party server. It can encrypt and transmit files that need to be synchronized among multiple devices without storing my files elsewhere.
Installation and usage on Windows#
For using Syncthing on Windows, I recommend using syncTrayzor. Of course, if you prefer using command-line tools, you can also use the official website.
You can see the interface by running the program, and the console at the bottom can be closed by clicking View > Console
.
If you use the official command-line tool, you can open the web control interface by running it and accessing http://localhost:8384.
Then, you can connect devices using their IDs to synchronize. First, obtain the ID of any device.
In the top right corner of the interface, there is an option to display the ID.
After obtaining the ID, use the "Add Remote Device" option on another device to add the device to the list of remote devices. It will send a connection request to that device, and once confirmed, you can select folders to synchronize.
Slow synchronization speed#
However, after configuring it, I found that the synchronization speed was very slow, almost crawling. For devices without a public IP, Syncthing uses relay servers for data synchronization, but the default relay server speed is disappointing.
There are two (or three) methods to achieve faster synchronization speed:
Personal VPS or ECS#
-
Install Syncthing on a server to obtain a public node, and then other devices can synchronize at high speed (the simplest method).
Most Linux package managers can directly obtain Syncthing.
sudo yum install syncthing
Then, modify the
gui > address
field in yourhome/username/.config/syncthing/config.xml
to0.0.0.0:port
, open the port corresponding to your server's security group, and then access the web GUI interface usinghttp://{host name[IP]}[:port]
. After that, it's the same as on Windows. Add the server to the list of remote devices on other devices and set up the synchronized folders. -
Set up a relay server on the server.
Use someone else's shared relay server#
There are also many people who have deployed their own relay servers and shared them for use. There are also several servers in China. You can refer to the list.