← Home

Setting up Syncthing (including on Termux)

25 March, 2025 - Categories: intro

I've decided to give Syncthing a fair shot - even though initially it seemed a bit overkill for me, running a whole webserver and using all-new protocols and discovery servers and all that just to sync some files.

Main reason is that I wanted to sync my phone, and my favorite syncing tool (unison sync by bcpierce00 and contributors) is not available on Termux.

The setup was simple enough on my arch linux server and desktop/laptop: install it, run it, navigate to the gui (using the reverse proxy on the server) and configure it there (disabling NAT traversal, relays and local discovery because i'd like to keep network noise to a minimum, likely i will also set up my own global discovery server soon for privacy reasons). Note that this setup is likely to break things for people who don't know port forwarding. Very conveniently, arch ships systemd user services for syncthing - you can just run systemctl --user enable --now syncthing.service and boom, it's active.

I'm also considering using my server's URL to specify the connection so i don't need a discovery service at all, since I already have the domain with proper dns setup and port forwarding for my homelab.

Next, the more complicated part: Termux.

first, I'd like Termux itself to start automatically, so i installed Termux:boot and followed it's instructions. Note: Termux:boot is an addon, and NEEDS to be installed from the same source as Termux itself, otherwise it won't work. I install both via Obtainium, but F-Droid works too, as long as you're consistent.

there's some nice instructions here on how to make it work for termux: https://github.com/termux/termux-packages/issues/5122

Next, I wanted to set it up as a service to ensure it's always running inside Termux, and to keep it easy to manage. termux-services provides Runit as a servie manager, which sounds fine to me. The one big hiccup i had here was that you need to restart your login session after installing termux-services, otherwise you get all kinds of weird errors.

Also, I think if you create the $PREFIX/var/service/syncthing folder and it's subfolders, you might have to CHMOD them to allow the runit user to access them, at least i got a bunch of permission errors while setting it up. also make sure to chmod +x any scripts you're setting up.

Now, let's see how it goes - how reliable is the sync going to be, and how is it going to affect my battery. Unison was nice because i could easily script it to run in whatever way i wanted, but not so nice because i often forgot to actually run it, leading to conflicts when i changed my password manager's db on both ends.