Setting up Syncthing for Raspberry Pi

Nowadays everything is apparently in the cloud. However the cloud comes in many different sizes and shapes. In my case primarily in the form of dropbox. However there are always downsides of “out sourcing” your data to an undefined cloud. Some popular alternatives include BitTorrent Sync (not open source and your data is still touched by a third party), ownCloud (an open source dropbox clone, however the performance on a Raspberry Pi is not very smooth) and since December 2013 Syncthing. The last one is a kind of open source implementation of BitTorrent Sync, so in contrast to Dropbox your data is distributed over your own computers and not at a distant server. In my setup I use a headless Raspberry Pi that is tucked a way in a cupboard as a node in the network, so this client is always online.

In this setup I’ve installed one Syncthing client on my Mac and one Syncthing client on my Raspberry Pi. The installation for Mac/Windows is very straightforward and just consist of downloading the right executable. After running your browser fires up and opens http://127.0.0.1:8080/ where you see the configuration and status overview.

Next ssh into your Rapsberry Pi and download the armv5 version of syncthing (check the latest release here)

wget https://github.com/calmh/syncthing/releases/download/v0.8.7/syncthing-linux-armv5-v0.8.7.tar.gz

Untar it

tar xvzf syncthing-linux-armv5-v0.8.7.tar.gz

And just run the executable. Note that the generation of the RSA certificate took almost 4 minutes!

pi@ERP ~/syncthing-linux-armv5-v0.8.7 $ ./syncthing
16:05:13 INFO: Generating RSA certificate and key...
16:08:55 OK: Created RSA certificate file
16:08:55 OK: Created RSA key file
[RPMIJ] 16:09:14 INFO: syncthing v0.8.7 (go1.2.2 linux-arm) jb@jborg-mbp 2014-05-16 14:28:52 UTC
[RPMIJ] 16:09:14 INFO: My ID: PRNIJ4CTJGG5VWZXLNPILFYA65EHKWSDDSJCATOVYT4YVMQVWVAQ
[RPMIJ] 16:09:14 INFO: No config file; starting with empty defaults
[RPMIJ] 16:09:14 INFO: Edit /home/pi/.config/syncthing/config.xml to taste or use the GUI
[RPMIJ] 16:09:14 INFO: Starting web GUI on http://127.0.0.1:8080/
[RPMIJ] 16:09:15 INFO: Populating repository index
[RPMIJ] 16:09:18 INFO: No UPnP IGD device found, no port mapping created (read udp4 0.0.0.0:53385: i/o timeout)
[RPMIJ] 16:09:18 INFO: Sending local discovery announcements
[RPMIJ] 16:09:18 INFO: Sending global discovery announcements
[RPMIJ] 16:09:18 OK: Ready to synchronize default (read-write)

The important piece of information is the unique ID: PRNIJ4CTJGG5VWZXLNPILFYA65EHKWSDDSJCATOVYT4YVMQVWVAQ

Now quickly switch back to you own computer and configure the client. Go to
http://127.0.0.1:8080/ and click on “Add a node”.
Paste the Node ID of the Raspberry Pi into the corresponding field, in this case
PRNIJ4CTJGG5VWZXLNPILFYA65EHKWSDDSJCATOVYT4YVMQVWVAQ

Then a new Peer node shows up that almost looks like this (without the In Sync part).

savenode

 

Click on the Edit button of the Default repository and check the box in front of Raspberry Pi (or whatever name you gave to the node you just added).

editresp

 

Now your computer is fully configured. Switch back to your Raspberry Pi and edit the  config file. We are now making the same adjustment as we did before in the GUI but now in the config.xml file.

nano /home/pi/.config/syncthing/config.xml

Add the Node ID of your own computer to the repository and node list sections

<repository id=”default” directory=”/home/pi/Sync” ro=”false”>
<node id=”PRNIJ4CTJGG5VWZXLNPILFYA65EHKWSDDSJCATOVYT4YVMQVWVAQ”></node>
<node id=”Insert the node ID of your computer (so not your Raspberry Pi) here”></node>
</repository>
<node id=”Insert the node ID of your computer (so not your Raspberry Pi) here” name=”Your computer name”>
 <address>dynamic</address>
</node> 

Save the file.
Now edit the rc.local file to startup syncthing at boottime.

sudo nano /etc/rc.local

And add the line

/home/pi/syncthing-linux-armv5-v0.8.7/syncthing &

Now every file you place in ~/Sync is synced to the other nodes in the network. Remeber to run syncthing -upgrade from time to time, since every week a new version is released with bug fixes.

Happy Synching!

15 Comments

Filed under Tools

15 Responses to Setting up Syncthing for Raspberry Pi

  1. donpillo

    Thank you for the HowTo.

    One Question, do i have to change/update the rc.local after doing “syncthing -upgrade” ? Cause i think the file name will change with every new version.

    • EricvdHelm

      Yep . But you can circumvent editing the rc.local by just making a symlink to the next version. So the only thing you need to do is update the symlink.
      ln -s ~/syncthing-linux-armv5-v0.8.7 ~/syncthing

  2. Bob

    How does it compare to Bittorrent Sync in ease of use when adding new repositories, sharing secrets etc. Can I create a root of folders that are synced with various users without syncing full root to all of them?

  3. roost

    Any reason you are using armv5 instead of armv7 or v6? is V5 specifically designed for PI?

  4. Ben Potter

    Thanks for this. I tried it, but failed to find an ARM version to use. I suspect this means I shall need to install go and build from source?

    Bear with me – am in charted waters!

    Many thanks for any help,

    Ben

  5. andi

    Hi there,
    also thanks for that how-to.
    Which OS have you running on the pi?

    Thanks,
    Andi

    • Ben Potter

      I was planning Raspbian, SAMBA server for the users (they’re chiefly Windozers, bless them) and Syncthing.

      All better ideas are most welcome!

      The software side is stalled while I strive to solve the problem of powering Pi and Samsung 2Tb drive via USB without frying the Pi’s innards….

      Ben

    • EricvdHelm

      I’m running headless Raspbian

  6. Ben Potter

    I am back here after a gap – the builders re-shaped the house, and I was project manager for my sins!

    The goal is to build 3 near-identical headless Pi systems, each with a hard disc partitioned into two equal parts. Each will be running SAMBA on one (local) partition, with the other acting as an off-site mirror for one of the other machines. I aim to use syncthing to do the mirroring of the whole partition, which is mounted as one directory.

    Am I right in thinking that this will best be achieved by running two instances of syncthing, each under a separate user?

    Many thanks,

    Ben

    • EricvdHelm

      Two users make sense in order to keep the access separated, I have no experience running two instances of syncthing on the same system though.

  7. Dave Wulkan

    I use a bunch of Trip Lite powered hubs. One port provides power to the pi and Trip Lite has an A/B cable so when you plug into the pi’s USB port you are not double feeding power to the pi. Also, the power supply from Trip Lite is very narrow so, I have no wasted AC ports on the power strip.

Leave a Reply to EricvdHelm Cancel reply

Your email address will not be published. Required fields are marked *