My Ubuntu server setup is a Gigabyte Brix j1900 8GB RAM, 120GB mSATA SSD and 3TB USB hard drive. I used Webmin to setup the Samba shares. I did initially setup the server to run from a 32GB USB3 stick and that worked fine but decided it might run faster from an SSD, although it boots faster, file transfer between the Samba shares and my desktop is the same, around 110 to 120MBs per second. I initially started out using the Brix to setup a home NAS after being disappointed with the performance of a WDMyCloud NAS. I tried FreeNAS, OpenMediaVault and Rockstor, all were very good at their job but after much testing of the various servers I decided the versatility offered by an Ubuntu server was worth looking into. Future plans include a VPN and security system based on motion which should all run on the server as it's hardly stretched with it's present duties.
I decided to write this post to help me to remember exactly how I'd setup and configured Syncthing on my Ubuntu 15:10 server. I know for a fact that in a few months I'd have forgotten how I did it and probably have to have gone through the whole learning process again.
Syncthing is a brilliant way to keep your files synchronised, it's private, runs on your own LAN and does just what it says on the tin.
There is now an official Debian repository for Syncthing here
This makes the installation very easy and to save flipping between websites I copied and pasted the instructions here.
Open a terminal console on your server, or if like me yours is a headless server with just power and a network connection use SSH.
Install Syncthing in Ubuntu / Linux Mint / Debian using its official repository
To add the official Syncthing (release) repository in Ubuntu, Linux Mint or Debian (and derivatives), use the following commands:
sudo apt-get install curl
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
echo "deb http://apt.syncthing.net/ syncthing release" |
sudo tee /etc/apt/sources.list.d/syncthing-release.list
sudo apt-get update
sudo apt-get install syncthing
That's it you've done it and you can test it runs by typing syncthing into terminal, you
should see a few lines of text
and info about the address of the web gui. (default 127.0.0.0).
If you're installing on a server then you'll need to change the address of the web gui by
editing the syncthing config.xml.
In terminal type sudo nano ~/.config/syncthing/config.xml
Look for this line
<gui enabled="true" tls="false"><address>127.0.0.0:8384</address>Change it to your servers address as in the example from my network below
<gui enabled="true" tls="false"><address>192.168.1.119:8384</address>ctl x and yes to save and exit
The next bit getting syncthing to start at boot I found the most tricky.
Ubuntu 15:10 uses systemd to start, systemd is a system and service manager for Linux that runs as PID 1 (Process ID 1) and starts the rest of the system. It uses a script file called a Unit for each service, they are located in /etc/systemd/system/multi-user.target.wants/ to get this to work you need to put this file into that directory.
This is how the directory listing looks
richard@ubuntu-server:/etc/systemd/system/multi-user.target.wants$ ls -l
total 4
lrwxrwxrwx 1 root root 31 Jan 29 18:26 atd.service -> /lib/systemd/system/atd.service
lrwxrwxrwx 1 root root 32 Jan 29 17:48 cron.service -> /lib/systemd/system/cron.service
lrwxrwxrwx 1 root root 37 Jan 29 18:26 dns-clean.service -> /lib/systemd/system/dns-clean.service
lrwxrwxrwx 1 root root 41 Jan 29 18:27 plymouth-quit.service -> /lib/systemd/system/plymouth-quit.service
lrwxrwxrwx 1 root root 46 Jan 29 18:26 plymouth-quit-wait.service -> /lib/systemd/system/plymouth-quit-wait.service
lrwxrwxrwx 1 root root 36 Jan 29 18:26 pppd-dns.service -> /lib/systemd/system/pppd-dns.service
lrwxrwxrwx 1 root root 36 Jan 29 17:48 remote-fs.target -> /lib/systemd/system/remote-fs.target
lrwxrwxrwx 1 root root 35 Jan 29 17:48 rsyslog.service -> /lib/systemd/system/rsyslog.service
lrwxrwxrwx 1 root root 31 Jan 29 18:26 ssh.service -> /lib/systemd/system/ssh.service
lrwxrwxrwx 1 root root 38 Feb 5 09:48 syncthing@richard.service -> /lib/systemd/system/syncthing@.service
-rw-r--r-- 1 root root 219 Feb 5 09:47 syncthing@.service
lrwxrwxrwx 1 root root 31 Jan 29 18:26 ufw.service -> /lib/systemd/system/ufw.service
I've highlighted the syncthing entry
This is the Unit text
***********************************************************************
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=http://docs.syncthing.net/
After=network.target
Wants=syncthing-inotify@.service
[Service]
User=%i
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
[Install]
WantedBy=multi-user.targe
***********************************************************************
Copy this file into the etc/systemd/system/multi-user.target.wants directory and name it with the service username you login as. Mine is labelled richard so it's called syncthing@richard.service
From terminal type systemctl enable syncthing@yourname.service
From terminal type systemctl start syncthing@yourname.service
my example systemctl enable syncthing@richard.service
That's it, reboot your server to check syncthing starts and then you can start setting up the folders you want to sync from the webgui.
Hope this helps and I apologise in advance for any mistakes I may have made in my description, in defence I can say it all works and I know my knowledge of Linux had improved in both the setting up of syncthing and in writing this, my first blog post.