
In this article, we will
discuss Syncthing , a new open-source cross-platform application that runs on a client-server model and is designed to synchronize files between participants (P2P). The application is written in the Go language and in functionality it is similar to
BitTorrent Sync .
After reviewing the new service, we will try to install it on the Raspberry Pi and synchronize it with the laptop.
System overview
To synchronize files between nodes in a P2P network, a simple, efficient and secure
Block Exchange Protocol (BEP) was built. Syncthing implements the capabilities of this protocol, although it can be used in any software. The development is completely open, all source code is published on
Github . The protocol is also open, so any bugs can be immediately detected and corrected. The program is released under Mac OS X, Windows, Linux, FreeBSD and Solaris, easily configured via a convenient web interface, works in a local network or via the Internet.
This is how the administrative panel interface looks like:
')
Ready-made assemblies are available
on Github for all major platforms, and the site also has
documentation (English) and a
quick start guide (English) .
Program features:- Open source application and open protocol.
- Each node in the network is identified by a strong certificate.
- Block level synchronization support. With a small change in a large file, only the changed part will be synchronized.
- No artificial channel limiting
- The ability to explicitly specify which nodes will have a synchronized directory available.
- Synchronization of directories and files by the last modified date (so far without versioning support).
- The “master-slave” option, due to which other nodes will only be synchronized with this directory, but will not be able to change its contents.
- Management through a convenient adaptable web interface.
- Cross platform Windows, Linux, Mac OS X, FreeBSD and Solaris operating systems are supported. There is an unofficial client for Android.
- Security and privacy. Data is stored on client machines, no interaction with a third-party server is required. TLS supported.
Installation and Setup
Now, after a brief review, we proceed directly to installing and configuring the application. I will use the home MacBook as the main host with a web interface, and the client will be installed on the Raspberry PI model B.
On macbookGo to
the download page of the current release and download the required archive, for Mac OS you need to download
syncthing-darwin-amd64-v0.8.13.tar.gzlist of currently supported platforms:
Unpack the downloaded archive and run the
syncthing file in the program
folder.
We wait until the end of the program and find the following line in the console:
My ID: WFDJGOXZBKCC45BFO36JCTFM2EPIKSPXZACUZAUTXRYD2RJAELGS
This is the system identifier, remember it, it will be useful to us a little later. Now let's deal with a client.
On Raspberry PiGo to the Raspberry Pi console and download the package for this platform:
wget https://github.com/calmh/syncthing/releases/download/v0.8.13/syncthing-linux-armv5-v0.8.13.tar.gz
Now unpack and run the service.
tar xvzf synct* cd synct* ./syncthing
It is necessary to wait some time until the unique key identifier is generated and also to remember (write) it.
After that, you need to add the first key generated on the laptop to the config.xml configuration file.
nano /home/pi/.config/syncthing/config.xml
and add the “laptop” ID to the
repository branch, as well as the new node:
<repository id = "default" directory = "/ home / pi / Sync" ro = "false">
<node id = "raspberry-pi-ID"> </ node>
<node id = "your-id-computer"> </ node>
</ repository>
<node id = "your-id-computer" name = "host name"> <address> dynamic </ address>
</ node>
I did it like this<repository id = "default" directory = "/ home / pi / Sync" ro = "false" ignorePerms = "false">
<node id = "EGOE6LPEVKJQ3EVYJNZJ2QC6NHTQA7L5SPCOGCSZ33DTLTTCM22D"> </ node>
<node id = "WFDJGOXZBKCC45BFO36JCTFM2EPIKSPXZACUZAUTXRYD2RJAELGS"> </ node>
<versioning> </ versioning>
</ repository>
<node id = "EGOE6LPEVKJQ3EVYJNZJ2QC6NHTQA7L5SPCOGCSZ33DTLTTCM22D" name = "raspberrypi">
<address> dynamic </ address>
</ node>
<node id = "WFDJGOXZBKCC45BFO36JCTFM2EPIKSPXZACUZAUTXRYD2RJAELGS" name = "macbook">
<address> dynamic </ address>
</ node>
In general, the configuration file is quite well readable and it has parameters that you can, and for more information you can refer to the documentation.
Client setup on the Raspberry Pi is complete, it remains to restart the service with the command
./syncthing &
Or add it to startup in the /etc/rc.local file.
Operation check
Open in the browser of the laptop again the address
http://127.0.0.1:8080 and in the upper right corner select Edit → Add Node

In the window that appears, fill in the fields, specifying the previously received Raspberry Pi ID, the host name.
Address field is left “dynamic”.

Let's try to synchronize directories. By default, a synchronization folder is created in ~ / Sync / on each node.
We put the file and after a while it will be synchronized with the other nodes.
Now you can synchronize data between machines using the fast protocol. To exchange files, all you need to do is to communicate the ID of your computer to the person with whom you want to organize joint storage.
Statistics
Load on Raspberry PiFrom Syncthing admin panel:
RAM Utilization: ~ 10MB
CPU Utilisation: ~ 1% in idle mode and up to 60% in the synchronization process.
Display of memory and processor consumption statistics at the moment of synchronization (htop)
Load Macbook Pro'13From Syncthing admin panel:
RAM Utilization: ~ 20MB
CPU Utilisation: ~ 12 - 30%
Screen statistics from the system utility Activity Monitor

In the process of collecting statistics, found that if the admin panel is open in the browser, the use of CPU time increases many times (from 5 to 40%) While the background process (without admin) consumes only 2-4% For example, Bittorrent Sync consumes 5−9%. The data, of course, is relative and depends on the iron of other factors, but some conclusions do allow.
The basis of the conclusion - do not leave without the need to open the admin panel in the browser, even in the background tab.
Conclusion
How much this application is more convenient and more efficient than the same Bittorrent Sync - to which I was already used - time will tell. The post is written in hot pursuit after just a couple of hours after finding information about Syncthing.
Write in the comments your questions, I plan to test the service and, I will try to supplement the post with information about synchronization speed, load, etc., if it will be interesting.
Related Links
Project on Gihaba:
github.com/calmh/syncthing#
Actual versions of the program for various platforms:
github.com/calmh/syncthing/releases/latest
Documentation:
discourse.syncthing.net/category/documentation
Support Forum:
discourse.syncthing.net
Startup Script for Raspberry Pi (Debian):
gist.github.com/arudmin/5a13e9105814c3f568ec