Sync files across all computers using Syncthing

Last updated on 2021-06-09 Tagged under  # linux  # network  # android

Part of "New life for an old laptop as a Linux home server"

These are my notes from this Youtube tutorial. Well worth watching!

Syncthing is a continuous file synch program. It synchronizes files between multiple computers in real time. My home setup is a star layout; that is, I have multiple devices that exchange data with a central home server.

Example: Setup with 3 computers - a server, desktop, and laptop - with each computer having Syncthing installed.

After travelling and working with my laptop, I return home and - when my laptop connects to the LAN - any file changes are synced with the server, which in turn syncs with the desktop.

Install

For installing the latest stable package for Debian/Ubuntu, see apt.syncthing.net.

Startup

On each computer, setup a systemd unit to automate the startup.

Add the systemd service ...

$ wget https://raw.githubusercontent.com/syncthing/syncthing/main/etc/linux-systemd/system/syncthing%40.service
$ sudo chown root: syncthing@.service
$ sudo mv syncthing@.service /etc/systemd/system
$ sudo systemctl daemon-reload

Enable and start Syncthing for your username ...

$ sudo systemctl enable --now syncthing@<username>
$ systemctl status syncthing@<username>

A default folder for synchronization - ~/Sync - is created.

Localhost GUI

On the local device, access Syncthing's GUI via the following URL: http://127.0.0.1:8384/

Remote host GUI

By default, we can't connect to the GUI running on a remote computer (program is only listening for connections from 127.0.0.1).

Allow connections to the GUI from network devices by logging into the remote computer, then editing ~/.config/syncthing/config.xml. Change the line ...

<gui enabled="true" tls="false" debugging="false">
 <address>127.0.0.1:8384</address>

... to ...

<gui enabled="true" tls="false" debugging="false">
 <address>0.0.0.0:8384</address>

... and restart sudo systemctl restart syncthing@<username>.

Syncthing GUI on remote host is now accessible at port <ip_address>:8384. Go to Settings-GUI and add a username and password to the web interface.

Add devices

On the remote device, go to Actions->Show ID, copy the string, and on each local device click on Add remote device and paste string in Device ID. A notification appears on remote device to add new device. Click OK and configure.

Add folders

See this video tutorial for adding a folder for synchronization.

Syncthing on Android

Install on phone: Google Play

Add remote device:

Share phone folder (example: Camera folder at /storage/emulated/0/DCIM):


» Later: A backup you don't have to think about is a backup that gets done

« Earlier: Remotely unlock a LUKS-encrypted Linux server using Dropbear