⌂ Self-hosting

Syncthing: syncing files between devices without a cloud

How Syncthing works: device IDs, folder types, file versioning, ignore patterns and practical setups for home and work, with no central server needed.

Not all self-hosting requires an always-on server with a web interface. Syncthing is an open source program that syncs folders directly between devices, with no central service holding the files. The laptop, the desktop PC, the phone and perhaps a NAS exchange changes among themselves, encrypted, whenever they are connected.

The operating model

Each Syncthing installation generates a device ID, a long string derived from its certificate. To connect two devices you add each other's IDs: there are no accounts, passwords or sign-ups. Communication uses TLS, and each side verifies the other's identity through its certificate.

To find each other, devices use:

  • local discovery, which finds them on the same home network;
  • global discovery servers, which say at which address an ID can be reached;
  • relays, used only when a direct connection is impossible, for example behind restrictive NAT. Data passes through the relay already encrypted.

If you prefer not to depend on any public infrastructure, you can disable global discovery and relays and enter device addresses by hand, or host your own discovery server and relay.

Folder types

The most important choice for each shared folder is its type:

Type Behaviour Example use
Send & receive changes flow in both directions work documents between PC and laptop
Send only the device publishes but ignores others' changes the phone's camera folder
Receive only the device receives but does not propagate its own changes the copy on the NAS

A very robust setup for phone photos is: phone as "send only", NAS as "receive only". If something on the NAS is changed by mistake, the change does not travel back to the phone; the interface then lets you revert to the original state.

File versioning

Syncthing is not a backup, but file versioning provides a safety net against deletions and overwrites coming from other devices. It is configured per folder:

  • trash can: deleted or replaced files are moved to a .stversions folder, optionally with a maximum age;
  • simple: keeps a fixed number of previous versions;
  • staggered: keeps more recent versions and progressively fewer as they age;
  • external: delegates to a custom command.

Versions are saved on the device that receives the change, not on the one that makes it. This is why you should enable them at least on the device acting as the archive, such as the NAS or desktop PC.

Excluding what you don't need

The .stignore file at the root of the folder lists what should not be synced. A typical example for a projects folder:

// temporary files and caches
(?d).DS_Store
(?d)Thumbs.db
*.tmp
node_modules
.cache

The (?d) prefix allows Syncthing to delete those files if they prevent a folder from being removed. Remember that .stignore is not synced: each device has its own, and if you want shared rules you can create a synced file and include it with the #include directive.

Concrete use cases

In my work Syncthing often shows up in these setups:

  1. Notes and documents in Markdown between laptop, PC and phone, with no application server.
  2. The phone's camera folder to the NAS, as a first step before the real backup.
  3. Personal configuration (editor settings files, scripts) across several computers.
  4. A remote copy to a relative's computer in another home, receive-only and with versioning enabled.

The last case is interesting: two homes running Syncthing get a geographically separate copy without subscriptions. To make it a real backup, though, you need versioning enabled and, ideally, a periodic snapshot on the destination device.

Typical problems

  • Conflicting files. When the same file is modified on two devices before syncing, Syncthing keeps both versions, renaming one with sync-conflict in its name. Look for them and resolve them periodically.
  • A phone that won't sync. On Android, battery saving can suspend the app: exclude it from battery optimisation. On iOS there is no official app; third-party clients exist, with limits tied to background operation.
  • An empty folder that empties everything. If a disk is not mounted and the folder appears empty, Syncthing notices the missing .stfolder marker and pauses the folder instead of propagating the deletion. Never delete that marker.

In short

  • Syncthing syncs folders directly between devices, with no accounts or central server.
  • Devices authenticate with certificates; global discovery and relays can be disabled or self-hosted.
  • The "send only" and "receive only" folder types prevent many mistakes.
  • Versions are saved on the device receiving the changes and should be enabled on the archive.
  • It is not a complete backup, but it is an excellent building block for one.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also