enpitsulin

enpitsulin

这个人很懒,没有留下什么🤡
twitter
github
bilibili
nintendo switch
mastodon

Use Syncthing to synchronize code

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 would use a git repository to synchronize after completing 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 issue of npm dependencies. The size of node_modules is really terrifying, so it is also important to be able to support filtering custom content.

Using cloud storage#

Before trying Syncthing, I tried using cloud storage such as Baidu Cloud and Onedrive to synchronize files. However, the cost was a bit expensive and I couldn't filter out the things I didn't want to synchronize. In general, it didn't meet my goals.

Although I bought a one-year subscription to Baidu Cloud Drive svip, 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, and it will not store my files elsewhere.

Installation and usage on Windows#

For using Syncthing on Windows, I recommend using syncTrayzor. Of course, if you prefer to use 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 going to View > Console.

syncTrayzor|1341x769

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.

Display ID|263x351

After obtaining the ID, use the "Add Remote Device" option on another device to add it to the list of remote devices. It will send a connection request to that device, and after confirmation, you can select folders to synchronize.

Slow synchronization speed#

However, after configuring it, I found that the synchronization speed was very slow, almost crawling. Because for devices without a public IP, Syncthing uses relay servers for data synchronization, but the default relay server speed is really disappointing.

There are two (or three) methods to achieve faster synchronization speed:

Personal VPS or ECS#

  1. Install Syncthing on a server to obtain a public node, and then the other devices can synchronize at high speed (the simplest method).

    Most Linux package managers can directly obtain Syncthing.

    sudo yum install syncthing
    

    Then, in your home/username/.config/syncthing/config.xml, modify the gui > address field to 0.0.0.0:port and open the port permissions corresponding to your server's security group. Then, access the web GUI interface by visiting http://{host name[IP]}[:port], and it's the same as on Windows. Other devices can add the server to the list of remote devices and set up the synchronized folders.

  2. Set up a relay server on the server.

    Refer to this

Use a shared relay server#

There are also many people who have deployed their own relay servers and share them for use. There are also several servers in mainland China. You can refer to the list.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.