This article will show you how to install and configure SyncThing. This software will allow you to sync to another computer or device via the BitTorrent protocol.
You'll need to execute some commands via SSH to use this software. There is a separate guide on how to connect to your slot via SSH. Commands are kept as simple as possible and in most cases will simply need to be copied and pasted into the terminal window (then executed by pressing the Enter key).
Table of contents
Install SyncThing by logging in via SSH, then copying and pasting the following:
wget -qO ~/syncthing.tar.gz https://github.com/syncthing/syncthing/releases/download/v1.9.0/syncthing-linux-amd64-v1.9.0.tar.gz mkdir -p ~/bin; tar xvzf ~/syncthing.tar.gz -C ~/; mv ~/syncthing-linux-amd64-v1.9.0/syncthing ~/bin/; chmod +x ~/bin/syncthing; ~/bin/syncthing -generate="~/.config/syncthing" rm ~/syncthing.tar.gz ; rm -rf ~/syncthing-linux-amd64-v1.9.0
Configuring before starting Syncthing
The config needs to be tweaked before you can run Syncthing. Copy and paste these commands:
sed -i 's|127.0.0.1:[0-9]*|0.0.0.0:'$(shuf -i 10001-49000 -n 1)'|g' ~/.config/syncthing/config.xml sed -i 's|<localAnnounceEnabled>true</localAnnounceEnabled>|<localAnnounceEnabled>false</localAnnounceEnabled>|g' ~/.config/syncthing/config.xml sed -i 's|<natEnabled>true</natEnabled>|<natEnabled>false</natEnabled>|g' ~/.config/syncthing/config.xml
Starting, stopping and restarting
This section covers the SyncThing process - starting it, stopping it and restarting it. It also covers checking if the process is running, in case that becomes necessary.
- screen -dmS syncthing ~/bin/syncthing && echo http://$(hostname -f):$(sed -rn 's|.*<address>0.0.0.0:(.*)</address>.*|\1|p' ~/.config/syncthing/config.xml)
- check running
- pgrep -laf syncthing
- pkill -f syncthing
- pkill -f syncthing && sleep 5 && screen -dmS syncthing ~/bin/syncthing && echo http://$(hostname -f):$(sed -rn 's|.*<address>.0.0.0:(.*)</address>.*|\1|p' ~/.config/syncthing/config.xml)
- kill (force stop)
- pkill -9 -f syncthing
The check running command will return a process number if SyncThing is running. If it doesn't return anything, SyncThing is not running.
Automatically restarting SyncThing if it is not running
Cron jobs can be used to check if SyncThing is running and start it up if it is not. There is a separate page on configuring cron jobs.
Creating a username and password for the webUI
Once you access the webUI using the URL provided by the start command you'll get a popup asking whether you want to send anonymouse usage reporting, dismiss it by accepting or not. Once it's done you will see an information that there is no password set up for webUI, click on Settings button and proceed to GUI tab to set password for the account.
By default syncthing will use as many threads as there are cores on the server. This concurrency leads to the disk being easily overwhelmed slowing down performance for your own programs and others on the server. Here's how to limit concurrency so that it doesn't cause any problems:
At the top-right of the menu, select the drop-down "Actions" then "Advanced". Under "Options" change "Max Folder Concurrency" to 0 (all cores) to 1. Then for each "Folder ..." listed change "Hashers" from 0 to 1. You will then need to click "Save" to apply the settings.
If you experience issues or crashes using SyncThing the first thing to try and do is restart the software using the command listed in the section above, Starting, stopping and restarting.
The commands below will completely remove the software and its config files - back up important data first!
pkill -9 -f syncthing rm -rf ~/.config/syncthing/ ~/bin/syncthing ~/Sync