Syncthing Backup

Posted onby

For this guide let’s assume you have two machines between which you wantto synchronise files. In keeping with Syncthing terminology they aregoing to be called “devices” in the rest of the documentation. The“local device” is the one you are configuring, viewing status for, etc.,while the “remote device” is the other machine.

I am running Syncthing on my Raspberry Pi2 which is running OSMC (based on debian upstream). Now I want to do a clean install of my Raspberry Pi2, but I when I install Syncthing again, I want to make sure I don’t have to configure all sync folders again and also make sure Syncthing wont have to scan all directories again, generate keys etc etc. How can I create a backup of Syncthing itself. Works on Mac OS X, Windows, Linux, FreeBSD, Solaris and OpenBSD. Run it on your desktop computers and synchronize them with your server for backup. Syncthing doesn't need IP addresses or advanced configuration: it just works, over LAN and over the Internet. Every machine is identified by an ID. Brief: Syncthing is an open-source peer-to-peer file synchronization tool that you can use for syncing files between multiple devices (including an Android phone). Usually, we have a cloud sync solution like MEGA or Dropbox to have a backup of our files on the cloud while making it easier to share it. The solution is: On the device sending the backups: set Folder Type to 'Send Only' On the device (s) receiving the backups: set File Versioning. Recommended setting is 'Staggered'.

Syncthing Backup

The best way to follow this guide is to do the install on both machinesand configure them in parallel. If both machines aren’t accessiblesimultaneously that’s fine, the results will just be a little lessimmediately obvious.

A film version of this transcript is available on YouTube (contributed [email protected]). This videoshows how to install Syncthing on Ubuntu/Debian/Mint using PPA, also availablein German. This video shows how to install Syncthingon Windows, also available in German.

Installing¶

Syncthing Windows 10

We suggest you have a look at the Community Contributions which letyou pick a flavor of Syncthing that best fits your scenario. For example, if youare interested in a cross-platform GUI application you can check outSyncthing-GTK. The community has also developed Windows, Android and manymore specific flavors that help you run Syncthing on your devices. Currentlyall community flavors run the same Syncthing core underneath, so don’t worryabout changing your flavor at a later point in time. The remainder of this pagewill explain how to set up two devices with the core Syncthing flavor.

Syncthing¶

Grab the latest release of Syncthing for your operating system and unpackit (if you use Debian/Ubuntu you may want to use Debian repository). There will be a binary called syncthing (or syncthing.exe onWindows). Start this in whatever way you are most comfortable with;double-clicking should work in any graphical environment, but I’ll use thecommand line to better illustrate what happens. At first start Syncthing willgenerate a configuration file, some keys and then start the admin GUI in yourbrowser. Something like the following will be printed in the command line:

At this point Syncthing will also have set up a folder calledDefaultFolder for you, in a directory called Sync in your homedirectory. You can use this as a starting point, then remove it or addmore folders later.

Configuring¶

The admin GUI starts automatically and remains available onhttp://localhost:8384/. Cookies are essential to the correct functioning of the GUI; please ensure your browser accepts them. It should look something like this:

Syncthing Backup System

On the left is the list of “folders”, or directories to synchronize. Youcan see the DefaultFolder was created for you, and it’s currentlymarked “Unshared” since it’s not yet shared with any other device. Onthe right is the list of devices. Currently there is only one device:the computer you are running this on.

For Syncthing to be able to synchronize files with another device, itmust be told about that device. This is accomplished by exchanging“device IDs”. A device ID is a unique, cryptographically-secureidentifier that is generated as part of the key generation the firsttime you start Syncthing. It is printed in the log above, and you cansee it in the web GUI by selecting “Actions” (top right) and “Show ID”.

Two devices will only connect and talk to each other if they are both configured with each other’s device ID. Since the configuration must be mutual fora connection to happen, device IDs don’t need to be kept secret. They are essentially part of the public key.

To get your two devices to talk to each other click “Add Remote Device”at the bottom right on both, and enter the device ID of the other side.You should also select the folder(s) that you want to share. The devicename is optional and purely cosmetic. It can be changed later ifrequired.

Once you click “Save” the new device will appear on right side of theGUI (although disconnected) and then connect to the new device after a minute or so.Remember to repeat this step for the other device.

At this point the two devices share an empty directory. Adding files tothe shared directory on either device will synchronize those files to theother side.

If you are using a Syncthing flavor that adds OS specific functionality (e.g. the Android app), you may need to access the Web GUI to enable syncing folders, and other configuration options.

Good luck and have fun! There is more documentation and if you run into trouble feel free to posta question in the support forum.If you have problems getting devices to connect, first take a look atFirewall Setup, then look at any error messages in the GUI or on theconsole. Don’t forget that configuration changes will not be reflectedinstantly - give Syncthing a little time, especially after a restart.

I wanted to replace rsync for my current host backups.

I had 2 hosts (1 laptop and 1 desktop) that would get there changes polled from a backup server. (polled = cronjob ran every hours)Ofcourse those boxes are not always on and a frenzy of cron mails happen every now and then.

I replaced everything with syncthing, they have clients available for linux, illumos, openbsd and mac.With the config below (client::folder master = yes, server::folder master = no) we prevent the server from accidentally overriding a file on the client. The client knows the server's IPv4 and/or IPv6 address so we do not need global or local discovery nor UPnP.

We leave the client's set to dynamic on the the server side to prevent the server from making connection unless the client says hello first. When the laptop is online but not in my LAN it won't see the server so it won't sync (what I want, although you could manually open up your firewall to allow this).

The server is more or less passive and only takes files the clients give to it.

server and client setup

backup_server:

  • disabled global discovery
  • disabled local discovery
  • disabled upnp
  • disabled start browser
  • bound to: tcp://ipv4:22000, tcp://[ipv6]:22000
Server

client1:

  • disabled global discovery
  • disabled local discovery
  • disabled upnp
  • bound to: tcp://0.0.0.0:22000 (dynamic)

client2:

  • disabled global discovery
  • disabled local discovery
  • disabled upnp
  • bound to: tcp://0.0.0.0:22000 (dynamic)

adding the backup server to the client

Syncthing Backup Phone

  1. click 'add device' on client X's GUI
  2. device id: server's id
  3. device name: backup server
  4. address: tcp://server-ipv4:22000, tcp://[server-ipv6]:22000 (IMPOTANT, client will reach out to server)
  5. compression: off for LAN, all data for remote
  6. introducer: no

adding a directory to backup

  1. click 'add folder' on client X's GUI
  2. enter an ID: 'clientX-somedir'
  3. interval: 120 (or whatever you want)
  4. Folder Master: Yes (important, we configure this so we only sync from the client -> server)
  5. Pull Order: Alphabetical (seems to work best in case of conflicts)
  6. Share With Devices: 'backup server'

Syncthing Linux

... now open the backup server's GUI and wait ...

Syncthing Backup Reddit

  1. accept the new device

  2. ...

  3. address: dynamic (IMPORTANT)

  4. accept the new 'folder'

  5. check if ID: 'clientX-somedir'

  6. interval: 0 (don't rescan, backup server should NOT have changes)

  7. Folder Master: No (important, we configure this so we only sync from the client -> server)

  8. Pull Order: Alphabetical (seems to work best in case of conflicts)

  9. Share With Devices: 'clientX'