[HowTo] Install and use SyncThing on OSMC

UPDATE: you can now semi-automatically install Syncthing.

OPTION1: AUTOMATIC INSTALLATION
This will install SyncThing and configure the mediafolder that will contain the Sync folder.

  1. Download my OSMCautosetup script:
    wget https://gist.githubusercontent.com/zilexa/7a654cd18c9ec663f4daa1a791a5f99e/raw/be532deec710c2e82a269ec74468603cbb2fdb86/OSMCautosetup.sh

  2. Now edit it, set a 0 for the apps/configurations you don’t want and a “1” for SyncThing, also set the path to the mediafolder/harddrive or network location that should contain the Sync folder, where it will sync your files:
    nano OSMCautosetup.sh
    (save the file with CTRL+O, exit the editor with CTRL+X)

  3. Now run the script: sudo bash OSMCautosetup.sh

OPTION 2: MANUAL INSTALL:
Official information from Syncthing to install on Debian based systems: http://apt.syncthing.net/

This HowTo discusses how to manually do the following (note my OSMCautosetup from option 1 does all of this for you):
Installation
Autostart on boot
Remote WebUI
And will follow the exact guidelines from Syncthing with respect for the file structure and methods used by OSMC.

Installation

  1. Add the release PGP keys:

    curl -s https://syncthing.net/release-key.txt | sudo apt-key add -

  2. Add the “release” channel to your APT sources:

    echo “deb http://apt.syncthing.net/ syncthing release” | sudo tee /etc/apt/sources.list.d/syncthing.list

  3. Update and install syncthing:

    sudo apt-get update
    sudo apt-get install syncthing

Autostart on boot
4) create the following file

sudo nano /lib/systemd/system/syncthing.service
  1. copy paste the following, hit CTRL+O to save, CTRL+X to exit.

    #Syncthing systemd service file for OSMC
    #Path should be /lib/systemd/system/syncthing.service

    [Unit]
    Description=Syncthing - OSMC
    Documentation=http://docs.syncthing.net/
    After=network.target
    Wants=syncthing-inotify@.service

    [Service]
    User=osmc
    Nice=7
    Environment=STNORESTART=yes
    ExecStart=/usr/bin/syncthing -no-browser -logflags=0
    Restart=on-failure
    SuccessExitStatus=2 3 4
    RestartForceExitStatus=3 4

    [Install]
    WantedBy=multi-user.target

  2. now enable the service and start it

    sudo systemctl enable syncthing.service
    sudo systemctl start syncthing.service

You can check if Syncthing has started succesfully:

sudo systemctl status syncthing.service

Configuration
7) Edit the Syncthing configuration:
stop the service first sudo systemctl stop syncthing.service
open the config file in the editor: nano /home/osmc/.config/syncthing/config.xml

  • On line 2, change the following path="home/osmc/sync/" to the default path you want to use. For example in my case, it is my attached USB drive: path="/media/UsbDriveName/"

  • Also a bit further down the file, change the GUI Listen Address setting from the default 127.0.0.1:8384 to
    0.0.0.0:8384. This is required for remote access of the webUI.

  • Start Syncthing again: sudo systemctl stop syncthing.service

DONE!

Remote WebUI (access Syncthing from other computers)
To access the webui, enter the IP of your OSMC device in a browser, for example: 192.168.1.1:8384
You will never need to do anything via SSH. Everything can be done via the webUI. To access this webUI and any other services like transmission when you are not at home, read my (suprisingly simple!) SSH Tunneling guide. No need to open ports in your router!

3 Likes

To be able to edit the file /home/osmc/.config/syncthing/config.xml syncthing has to be run at least once to create the file.

Thanks I have moved that step to the bottom.

what types of things are you using synching for with osmc?

You can use for whatever you want. I’m using for synching photos from my phone to external disk on pi. And with cron jobs I have scheduled to organize photos by date and move them into folders by month. So I don’t need to do it manually with connecting it to PC. You could maybe use it to sync two computers or create backups of files from PC to external disk. Use your imagination :stuck_out_tongue:

1 Like

Thanks a lot it is very clear!
There is just a very little mistake at the end:
sudo systemctl start syncthing.service

thanks!

Works like a charm.
Kudos.

EDIT:
after reboot, can’t access to OSMC via SSH.
What’s the problem?

Do you have external address or external ip? Try with this if you have port forwarding enabled. I’ve got problems when I setup vpn and only works with external address. Maybe will this be helpfull :slight_smile:

Oops nenad.
Sorry I missed your answer.

Well, after a second reboot I was able to connect through SSH to OSMC.
Sorry (again) to not having said it.

And thanks!

I have updated the first post: you can now automatically install SyncThing (and other stuff) using a script. It’s added as option 1.

Hi, I install Syncthing with that automatic script. Everything install correctly but what to do after that ? web UI don’t work.
After that I try manual installation by ssh on my smartphone, everything goes well and on point 6 when I type: [quote]
sudo systemctl enable syncthing.service
[/quote]
I had messege:

hi, how to remove all that I’ve installed with syncthing autosetup script because it doesn’t work and also my transmission web client don’t work :confused: ?

sudo systemctl stop syncthing.service
sudo systemctl disable syncthing.service
sudo apt-get remove syncthing
sudo rm /lib/systemd/system/syncthing.service
sudo reboot

Thanks, but my Transmission still doesn’t work. Can You help me completly reverse changes that script do?

The logs should tell you why transmission doesn’t work…

It would probably take less time to re-install. I have no idea what changes that script have made.

can You tell me what logs to look for ?

I’m sorry, it will clearly take less time to simply re-install…

do You know some fast method to reinstall osmc and save my data ?

I have no idea exactly what you refer to as your “data” but if you are referring to your Kodi configuration, simply copy your ~/.kodi folder to another device and re-image the card with OSMC. Afterwards, overwrite the existing ~/.kodi with your backup.

/.kodi folder is enough to save my installed apps configuration ?