SyncThing

SyncThing is a continuous file synchronization program. It synchronizes files between two or more computers in real time, safely protected from prying eyes. Your data is your data alone and you deserve to choose where it is stored, whether it is shared with some third party, and how it’s transmitted over the internet.

It also bypass the need for exposing your server to the internet due to the usage of an anonymous network or interface servers (which you could also host if you like).

It basically keep folders in synchronization between hosts. hosts can be computers and also mobile devices.

Remember: SyncThing is NOT A BACKUP solution for your server! (not even for your mobile devices, but if you backup your server, then it is)

Syncthing can be configured via a nice web interface.

Installation

Gentoo has an ebuild for SyncThing, so just emerge it:

emerge syncthing

Syncthing is configured via /etc/conf.d/syncthing file, where you can specify the user it will run as and the port it will bind to. Following the Gentoo way you can run more than one instance of syncthing, something you might want to do to separate instances by users.

There is a wiki page on Gentoo here if you want more details.

You want to run Syncthing as the user you need your data synched as.

After you have set it up, you should login as that specific user and run it once manually:

syncthing

then close it. This will create the basic internal configuration files needed.

You most probably don't want to run the standard instance of syncthing but always make a copy of it for the user or groups you want. For example, if you need to run a syncthing to sync your mobile phone stuff as user myuser, you will need to:

  • copy /etc/conf.d/syncthing to /etc/conf.d/syncthing.myuser
  • symlink /etc/init.d/syncthing to /etc/init.d/syncthing.myuser

then edit (see below) the config file and start the service:

rc-update add syncthing.myser default
/etc/init.d/syncthing.myuser start

Configuration (per user)

For SyncThing to be useful you need to run it as a specific user or group, and assign a unique port to it.

Edit the /etc/conf.d/syncthing.myuser configuration file:

synchting
SYNCTHING_GUI_ADDRESS="http://127.0.0.1:8384"
SYNCTHING_USER="myuser"
SYNCTHING_GROUP="users"
SYNCTHING_HOMEDIR="/home/myuser/.config/syncthing"
SYNCTHING_LOGFILE="/home/myuser/syncthing.log"

Remember to run syncthing manually once as the user:

su - myuser
syncthing

then stop it, before launching the service.

Reverse Proxy

Running syncthing under NGINX is easy, take this as example:

syncthing.conf
location /syncthing-myuser/ {
        proxy_pass http://127.0.0.1:8384/;
        proxy_read_timeout 120s;
        access_log off;
}

Just make sure the port is correct.

Usage

Open your browser to http://127.0.0.1/8384, use the correct port, and configure it.