Install Syncthing

Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized. It is an alternative to BitTorrent Sync and doesn't have the “stigma” associated with the “BitTorrent” phrase. I use this program to keep files synchronized between systems. Like my BitTorrent Sync installs, I have one server sitting in the “cloud” that is always on so that my various systems can always have the latest copies of the files and I don't have to deal with port-forwarding on firewalls. This “cloud” server typically is a Linux VPS system…

wget -nv -O - https://syncthing.net/release-key.txt | sudo apt-key add
 
sudo add-apt-repository "deb https://apt.syncthing.net/ syncthing release" 
 
sudo apt update
sudo apt install -y syncthing
 
syncthing --version
 
sudo mkdir -p /opt/syncthing
 
sudo syncthing -home="/opt/syncthing" -generate="/opt/syncthing"
 
sudo sed -i 's/<upnpEnabled>true<\/upnpEnabled>/<upnpEnabled>false<\/upnpEnabled>/g' /opt/syncthing/config.xml
 
sudo useradd -M syncthing
 
sudo chown -R syncthing:syncthing /opt/syncthing

Configure a startup script

cat > /tmp/syncthing.service << EOF
[Unit]
Description=Syncthing Server
Documentation=

Wants=network.target
After=network.target

[Service]
User=syncthing
Group=syncthing
KillMode=process
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

WorkingDirectory=/opt/syncthing
ExecStart=/usr/bin/syncthing -home="/opt/syncthing" -logfile="/var/log/syncthing.log"

[Install]
WantedBy=multi-user.target
EOF

sudo mv /tmp/syncthing.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/syncthing.service

sudo systemctl enable syncthing.service

sudo touch /var/log/syncthing.log
sudo chown syncthing /var/log/syncthing.log

cat > /tmp/syncthing << EOF
/var/log/syncthing
{
        rotate 4
        weekly
        missingok
        notifempty
        compress
        delaycompress
 }
EOF
sudo mv /tmp/syncthing /etc/logrotate.d/
sudo chown root:root /etc/logrotate.d/syncthing

Start Syncthing Service

sudo service syncthing start