Sync files across all computers using Syncthing

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

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 setup

My home setup is a star layout; that is, I have multiple devices - each with Syncthing installed - that exchange data with a central home server.

Example: 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.

1. Install

Use the latest stable version of Syncthing by retrieving the package from apt.syncthing.net.

Add the release PGP keys ...

$ sudo curl -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg

Add the stable channel to the package manager ...

$ echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list

Set a preference for Syncthing's packaged version vs the usual Debian/Mint/Ubuntu offerings ...

$ printf "Package: *\nPin: origin apt.syncthing.net\nPin-Priority: 990\n" | sudo tee /etc/apt/preferences.d/syncthing

Install ...

$ sudo apt update && sudo apt install syncthing

2. 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 (example: foo) ...

$ sudo systemctl enable --now syncthing@foo
$ systemctl status syncthing@foo

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

3. GUI

Localhost

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

Go to Settings-GUI and add a username and password to the web interface.

Remote host

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>

Restart ...

$ sudo systemctl restart syncthing@<username>

Remote host is now accessible at port <ip_address>:8384.

Go to Settings-GUI and add a username and password to the web interface.

4. Add devices and folders

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.

Folders

See this video tutorial for adding a folder for synchronization.

5. Syncthing on Android

Install on phone: Google Play

Add remote device

Share phone folder

Example: Camera folder at /storage/emulated/0/DCIM):

Thanks for reading! Read other posts?

» Later: Nginx web server

« Earlier: Transfer files between phone and computer via USB