Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet.
The above quote is from Syncthing's site. Syncthing is an Open Source software that syncs things across the internet. No matter where your machines are, as long as they are connectable. They even have a version for Android available at Google Play, or on F-Droid.
How I'm using Syncthing
So my new job has me working as a road warrior. This means I have a laptop that I use a lot for work while I am remote. However, my machine at home (nicknamed: Beast) has better processing power, more memory, and as a result performs much better than the laptop.
The first thought I had was, how can I make the process of working on code less painful by getting code from my laptop to Beast and back? Syncthing to the rescue!
Setting up Syncthing
First you have to get Syncthing installed. This is easy as almost all OSes and distros are supported. I found that Fedora isn't supported directly, so I just grabbed the
tarball and extracted it in
# Untar tarball to ~/.local $ sudo tar xvzf ~/Downloads/syncthing.tar.gz -C /usr/local/
To make executing Syncthing easy, you can symlink the executable into your path
$ sudo symlink /usr/local/syncthing/syncthing /usr/local/bin/syncthing
When you successfully run Syncthing a browser will open with your new running instance of Syncthing!
Introduce your Devices
So once you have it running you have to establish
Devices. What do you want to sync between, basically. I am syncing between
OPO (my Android based phone).
To do this you start Syncthing on each of the devices, and then share the device ID from each node. A hint here, if you use your Android as the
Introducer you save yourself some work.
Sync your Things!
Finally you are ready to sync things. From the machine where the things exist now, you add a
Folder and tell it what to share (the actual path) and then which devices to share it to. There are advanced options for timing, and master/normal sharing. I won't cover those but they are available.
Now, having Syncthing running when you fire up the executable is great, but wouldn't it be nice if Syncthing just started and did it's work each time you boot your machine?
No problem, just create a systemd
.service and then enable it. Here is how I did mine.
# Create a group and user for Syncthing $ sudo groupadd syncthing $ sudo useradd -g syncthing syncthing # Create .service file vim /firstname.lastname@example.org
# systemd service file for Syncthing [Unit] Description=Syncthing - Open Source Continuous File Synchronization for %I Documentation=man:syncthing(1) After=network.target Wants=syncthing-inotify@.service [Service] User=%i ExecStart=/usr/local/bin/syncthing -no-browser -no-restart -logflags=0 Restart=on-failure SuccessExitStatus=3 4 RestartForceExitStatus=3 4 [Install] WantedBy=multi-user.target
Finally enable Syncthing at startup
# Enable and Start Syncthing $ sudo systemctl enable email@example.com $ sudo systemctl start firstname.lastname@example.org
You now have Syncthing running at boot, and in the background.
If you happen to run into problems with starting Syncthing via systemd, you might want to test if SELinux is the problem.
# Check audit log for syncthing $ sudo cat /etc/log/audit/audit.log | grep syncthing # Temporarily disable SELinux $ sudo setenforce 0
If you find an error or disabling SELinux allows Syncthing to run then you need to adjust the labels of the executable (most likely). However, that is out of scope for this article.