Like most people with a smartphone, I like to keep my contacts and calendars backed up somewhere and synchronized between devices. To do that, I’ve been using Google, which integrates very well with Android, my preferred phone OS (as well it should, since they make the damn thing). The problem is that I don’t really want Google having all the data on my contacts and calendars if I can help it, because why should they?
I haven’t been able to find a good solution to this problem, but I wasn’t really looking for one very hard. That all changed (except the last part) when I stumbled upon someone recommending an open-source synchronization solution that’s very easy to set up. Starting out, I thought it would be pretty complicated, but it turned out to consist of installing one program and changing three lines of a configuration file.
This has all the advantages of Google for me (since I don’t share calendars with anyone) with none of the privacy issues, so I decided to try it out. I did, and I was amazed at both how easy it was to set up and how well it worked, so I decided to write the general gist up in a post in the hopes that it would help someone else. Here are the details!
Radicale
The server-based component of this operation is Radicale. It’s a small Python script that acts as a CalDAV/CardDAV server and synchronizes your contacts and calendars. Setting Radicale up on your computer or server is pretty easy:
$ sudo pip install radicale
And that’s that, Radicale is now installed. You may want to edit its configuration to change things like the port it listens to, rights management and where to store the files. Here’s my configuration, from ~/.config/radicale/config
:
[server]
# Only listen to localhost, as I have nginx proxy radicale.
hosts = 127.0.0.1:35593
[rights]
# Each authenticated user can only read their calendars.
# This is handled at the nginx level, through basic auth,
# but radicale also supports its own auth.
type = owner_only
[storage]
# Where to store the files.
type = filesystem
filesystem_folder = ~/.config/radicale/collections
If you want every single change committed in a git repo (so you can easily back it up and revert any wrong changes), just run git init
in your collections dir (specified in the config above). Contacts and calendars are just files, feel free to edit them by hand and see the changes reach your phone automatically!
DAVdroid
The second and final piece of the puzzle is DAVdroid. It creates a contacts/calendars provider on your phone so you can load the details on your server.
Setting it up is trivial: Just go into your settings, under accounts, create a new DAVdroid account and enter your Radicale URL with just your username! I took a long time to set up each and every calendar until I realized that DAVdroid can set them all up automatically. If your Radicale server is running at https://mycalendar.com/, just enter https://mycalendar.com/username/, and DAVdroid will show you all your calendars and address book so you can pick the ones you want to use.
Once you’ve added the account, you’ll see your contacts and calendars start to get populated, securely (if you’re using TLS) and privately!
This guide is for Android because that’s what I use, but the Radicale FAQ seems to indicate that setup on iOS is even easier. If anyone has set it up and can post a comment, I’d be happy to update this post.
Epilogue
So there you have it, a complete and private contacts and calendars syncing solution for Android and iOS, all in a few minutes! Setting Radicale up was much easier than I originally thought it was going to be, and it’s worth every second of effort just for the versioned contacts alone. Now I can delete, edit or add contacts with the complete peace of mind that my restored address book is just one git checkout
away.
If you have any comments or questions, get me on Twitter or leave a comment below!