This is a simple guide on how to synchronise contacts and calendars between a desktop operating system (Windows, macOS, Linux) and Android relying on a combination of Syncthing and Radicale. The main goal and idea is to have Radicale running on every system locally, so that you can connect with it even when there is no network connection available. This applies to both desktop operating systems and Android as well.
Desktop:
-
Install and run Radicale following instructions from https://radicale.org.
-
Use relative paths in the Radicale config file, so that everything is contained in the same folder.
-
For reference, my Radicale config looks somewhat like this:
[auth] type = htpasswd htpasswd_filename = users htpasswd_encryption = plain [server] hosts = localhost:5232 [storage] filesystem_folder = . type=multifilesystem_nolock
The last line, i.e.
type=multifilesystem_nolock
, is required when running Radicale on some filesystems, e.g. FAT on Android. -
Sync contacts via CardDAV and calendars via CalDAV between Radicale and a local client application, e.g. Thunderbird.
-
Add the whole local Radicale folder to Syncthing.
-
Add
.Radicale.cache
to the folderās ignore patterns. -
Share the Radicale folder from the desktop to the Android device.
Android:
-
Accept the shared Radicale folder, placing it somewhere on the internal storage, e.g.
/sdcard/Syncthing/Radicale
. -
Install Termux (https://wiki.termux.com/wiki/Installation).
-
Install Termux:Boot (https://wiki.termux.com/wiki/Termux:Boot).
-
In Android settings, give Termux permission to access files and also exclude the app from battery optimisation. The first is required for Radicale to access the Syncthing folder, and the second for DAVxāµ to trigger Radicale sync when in background.
-
Inside Termux, update repositories first:
pkg up
-
Install Python:
pkg install python
-
Install Radicale:
pip install radicale
-
Install Vim:
pkg install vim
Of course, you can use another text editor of choice instead.
-
Create a new text file called
radicale.sh
at~/.termux/boot
:mkdir ~/.termux/boot touch ~/.termux/boot/radicale.sh
-
Edit the newly created file with Vim:
vim ~/.termux/boot/radicale.sh
-
Inside the file, write:
#!/data/data/com.termux/files/usr/bin/sh cd "/sdcard/Syncthing/Radicale" python -m radicale --config="radicale.ini"
Note: This assumes that your Radicale config file is called
radicale.ini
. -
From now on, Radicale should start automatically on boot, and you can connect to it via a Web browser the same way as you would on the desktop.
-
Install DAVxāµ (https://f-droid.org/packages/at.bitfire.davdroid) and use it to sync contacts and calendars between Radicale and Android.
Note: if Data Saver is enabled in the OS, you need to exclude DAVxāµ from it, or otherwise nothing will happen when trying to run the sync (despite the fact that it happens fully offline ).
While this method may sound complicated at first, I have been using it for years now with zero issues. I had also tried using DecSync (https://github.com/39aldo39/DecSync) before, however it proved to be very buggy for me, hence I switched to this method instead. The main advantage is that Radicale runs locally both on the desktop and Android, which makes it possible to add, edit, and delete items offline, and Syncthing will sync the changes once connected. Of course, as with any other type of sync, simultaneous modifications on multiple devices will lead to conflicts, so you mustnāt edit the same events or contacts without syncing the previous changes first.
I also understand that this short guide assumes the user has already got some basic knowledge on how to install software and operate the command line. I may try to make the guide more beginner-friendly later on, but unfortunately Iām very limited on time right now, so Iāve only wanted to lay out the basic steps to follow along.
I hope someone will find this guide useful .
PS Inside Termux, you can test the script simply by executing it manually first, e.g. sh ~/.termux/boot/radicale.sh
in order to verify that it actually works while watching the output live before trying to start in on boot (and possibly debug any errors there).