Synchronize contacts between Android and Thunderbird
As of today, most of the phone comes with Android installed, which makes them "smart".
Unfortunately, it seems that being smart means that simple operations are no longer possible.
Everything needs to be connected, but to be connected one needs a permanent connection to the internet, send data to unknown servers, hope that it does not get saved in unknown locations or misused, and then send it back on our pc. And of course, it needs some app, and better be it compatible with our computer (or phone), as it uses some closed protocol. If unlucky, it requires some account, unnecessary permissions, and who knows what else.
Once upon a time I could connect my phone to my pc with a cable, and synchronized all contacts in a matter of seconds. Those were different times, most programs did not require or even acknowledged something like the existence of the internet. So if they were also a proprietary blob, it would have been very improbable for them to leak any information.
Granted, it might not have worked on all phones, but it did its job pretty well. As of today, something like that is not possible on Android.
It is not possible to access the data from any applications, contacts included. It is not possible to synchronize the content of the "Contacts" app, with something on the file system. It is (AFAIK), not possible to trigger the export and import action through other programs.
So one needs to export, merge and import by hand all the time, or synchronize with some external provider.
Most people might not care, but I saved a lot of personal information in my contacts. Things like birthday, phone number, email address, postal address, maybe a picture, links to different social accounts, some notes sometimes even something like their IBAN, social number, other private pieces of information, and so on.
I would not like most of my personal data to be given away without my consent, especially for no reason, and naturally, I try to do the same with the data of other people.
So using an external provider has never been an option for me, but fortunately, I found how to sync all the contacts without making them leave my home.
Radicale is the central piece to make everything work, as it works as a server, which makes the synchronization possible.
My current configuration is
# .config/radicale/config [storage] filesystem_folder = <where to store data> [server] hosts = 0.0.0.0:5232, [::]:5232 max_connections = 5 # 100 Megabyte max_content_length = 100000000 # 30 seconds timeout = 30 [auth] type = htpasswd htpasswd_filename = ~/.config/radicale/pass.local # encryption method used in the htpasswd file htpasswd_encryption = plain
To start the server, simply type
python3 -m radicale
Once Radicale is running, it is possible to connect to it and synchronize all contacts.
On Android, DAVx⁵ is probably the best program for synchronizing contacts and calendars.
As long as my phone can contact the pc (for example because they are in the same network), they can synchronize its content. Sometimes I wish using a cable would still be a thing, but I’m happy enough with this approach.
Unfortunately, if the name of the pc does not get resolved, it’s not simply possible to change in DAVx⁵ the name of the host with its IP address "on the fly". So synchronizing might not always work, depending on the network.
raspberry, vdirsyncer and khard
My current setup does actually look a little different.
At home I have, for various reasons, a pc running nearly all the time (a Raspberry Pi).
Thanks to it
I can synchronize calendars and contacts without having both my computer and my phone on at the same time
I know that the data does not leave my personal network, and/or control on what devices it lands
I also wanted to access and manipulate my contacts outside of the mail client. While vCard files are simple text files, it is nice to have something that would verify if the data has the right structure.
khard works well and is simple to configure. This program is completely optional, as it does not participate in the synchronization process.
My current configuration looks like following
# ~/.config/khard/khard.conf [addressbooks] [[contacts]] path = ~/comunication/contacts [general] debug = no default_action = list editor = editor [contact table] display = last_name group_by_addressbook = no reverse = no show_nicknames = no show_uids = yes sort = last_name localize_dates = yes [vcard] private_objects = Jabber, Skype, Twitter, GitHub, Facebook, Linkedin preferred_version = 4.0
And all my contacts are saved inside
The CardBook addon permits to synchronize to a local directory, so I pointed it to
What’s left is thus synchronizing the local directory with Radicale, which runs on the raspberry.
vdirsync does this job neatly and is also relatively simple to use.
My configuration looks like
# ~/.config/vdirsyncer/config [general] status_path = "~/.vdirsyncer/status/" ## Contacts [pair my_contacts] a = "my_contacts_local" b = "my_contacts_remote" # folders where contacts are actually stored collections = ["contacts"] [storage my_contacts_local] type = "filesystem" path = "~/comunication" fileext = ".vcf" [storage my_contacts_remote] type = "carddav" url = <url>:5232 username = <username> password = <password>
For synchronizing the computer I simply execute
vdirsyncer discover && vdirsyncer sync;
Putting it under revision control
The WebDAV protocol already has a versioning scheme and capabilities for handling (some) conflicts.
Unfortunately, it does not always do the intended action. This is one of the reasons I put
~/communication/contacts under revisions control. It gives me two features at once
a backup mechanism (in case, for example, I delete by accident a contact, or edit it incorrectly)
a potentially manually merge mechanism
Splitting an existing vCard file
When exporting contacts from some programs, the Android contact application too, they’ll generate a single
.vcf file with all contacts.
Having only one giant file makes it more difficult to manage changes.
Do you want to share your opinion? Or is there an error, same parts that are not clear enough?
You can contact me here.