I can no longer sync iOS’ Contacts with my macOS Catalina’s Finder (the iOS sync portion of iTunes is now built into the Finder in macOS Catalina); the OS insists I’ve iCloud configured for Contacts which I do not. I’ve gone through all the steps Apple recommends, done the upgrades and the reboots, but there’s nothing doing. All the swearing and threatening of moving to a different operating system aren’t really helping. This started sometime after I wrote about setting up macOS to “dial” a number using a shell script, but it cannot be related.

I was spilling my sorrows on Christoph who simply said he avoids all those issues by using CardDAV. I slapped my forehead: I’ve been using CalDAV for years, for synchronizing two calendars across devices: my own calendar across two Macs, an iPad, and an iPhone, and the family calendar across the family’s devices. How could I have forgotten about CardDAV?

Baïkal has served us well for many years (the modification timestamp on the configuration reads August 2013). Before looking at using it for CardDAV I thought I’d put it on my little FreeBSD system in a BastilleBSD jail. The calendar migration was easy enough but produced a litre or two of adrenalin when I watched one calendar after the other disappear from iCal. Anyway, I got the data imported and our small family was back in sync.

I then created a Baïkal address book for myself, set up macOS and an iPhone to use that, and created a pseudo person’s entry on the Mac and another on iOS, and experimented a bit with how long it takes either side to sync, etc. As soon as I was satisfied I copy/pasted all contacts from macOS’ internal address book to its CardDAV store. When my contacts showed up on the iPhone, I knew I was half in business. After an additional backup I cleared out all the local contacts on the Mac.


I recently had to purchase a new old phone for testing OwnTracks on Android and settled for a used Samsung Galaxy S8, a device which vastly exceeded my expectations. A really nice piece of kit, if only it weren’t for Android … #halfkidding

I went the whole hog and decided to see how well I could work with the S8 and purchased a copy of DAVx5 which is a really good and well thought-out bit of software. There’s an Open Source but I decided to pay for the software – developers must live off something other than applause and fresh air.

screenshot of contact on Galaxy S8

I can create, edit, and delete contacts on the S8 and DAVx5 will synchronize them back via CardDAV to my server. Just the way it ought to be.

CLI FreeBSD / Linux

I mostly use Mutt as an email client which means I want to be able to integrate whichever solution I come up with with these tools. A quick search led me to install vdirsyncer which enables me to synchronize my CardDAV server with a local directory of vCard files on the file system. If I change any of these files the utility can then synchronize the changes back to the server and, using a post_hook script I write, can version control the vCard files it receives on the file system. (Source code: vdirsyncer.) The program’s configuration file reminds me of OfflineIMAP’s and its operating principles are similar: I configure a local and a remote store which are kept in sync.

$ export REQUESTS_CA_BUNDLE=mensCA.crt
$ vdirsyncer discover
$ vdirsyncer sync

Now that I have a set of vCard files in a directory, I can use khard, an address book for the Unix command line, which reads, creates, and modifies these files, and which can also be integrated with other programs, suitable for my use with Mutt.

$ khard new ..
$ khard edit ..

$ vdirsyncer -v WARNING sync
$ khard list jolie
Address book: jpm-ab
Index    Name           Phone                          Email
1        Jolie, Jane    work, pref: +49 555 6302547    work, pref: jane.jolie@example.org

$ khard show jolie
Name: Jane Jolie
Full name: Jane Jolie
Address book: jpm-ab
    Birthday: 1969-07-10
    Nickname: jj
    work, pref: +49 555 6302547
    work, pref: jane.jolie@example.org
    OwnTracks: owntracks/jjolie/s8
    UID: 9245cfe6-256f-40d3-aabf-b3bab4601273
        - _$!<HomePage>!$_: jj.example.org
    Note: Actress

Khard is just an example; any program able to read or manipulate vCard files would be suitable.


mcds, written by Timothy Brown, is a Mutt CardDAV search program – a C program which uses a combination of curl and libxml2 to query a CardDAV server to obtain mail addresses from the vCards. The program uses a simple configuration file in which I can specify the URL to my server, a username and whether I want to use a ~/.netrc containing the clear-text password for the CardDAV endpoint. Alternatively I can configure it to use a GPG-encryped password file. And oh, the glory: mcds has a man page!

$ cat ~/.mcdsrc
url = https://example.org/dav.php/addressbooks/jpm/default/
verify = yes
username = jpm
password_file = /Users/jpm/.mcds-pw.gpg

$ mcds jane

jane.jolie@example.org  Jane Jolie

mcds and khard are quite different: the former queries an online CardDAV server for email addresses to present to Mutt, whereas the latter is more of an all-purpose address book (of sorts) for the command line, but it needs an additional utility (vdirsync) to get the data from and to my CardDAV server.

As I’m away from home and thus from my CardDAV server a lot I’ve settled for khard et.al., but who knows: I may have to rewrite the “away from home” portion of this sentence, and I’d then prefer mcds.


Thunderbird isn’t a client I use, but if I moved to FreeBSD or one of its desktop siblings, I likely would (in addition to Mutt), so I thought I’d do you the favor and see how well it supports CardDAV. It doesn’t really, because it lacks built-in support for CardDAV, but I found TBsync which, with Dav-4-TbSync, allow me to synchronize my CardDAV and CalDAV stores to it. I tested this on FreeBSD, and it seems to work well enough at a first glance.

Thunderbird addressbook entry for Jane

I can edit address book entries on Thunderbird and thanks to a builtin scheduler can automatically (or on-demand) synchronize changes back to the server. TbSync is open source and there’s a short getting started page.

Two people suggested I try CardBookAddon, a new Thunderbird address book based on the CardDAV and vCard standards, which I did, also on FreeBSD. The addon has very many options, and I had trouble finding where to configure my CardDAV server; I resorted to reading manual which often helps ;)

screenshot of Thunderbird's CardBook

Nice about CardBookAddon (source code) is that it integrates remote addressbooks and local ones. I’m thankful for the recommendation: this is likely the addon I would choose to use if I used Thunderbird.


CardDAVMATE is an Open Source CardDAV web client which is nice to use for editing some of the more esoteric (read: not available in the GUIs) vCard attributes, in particular those for spouse and the social profiles.

screenshot of Jane's card in carddavmate

The client runs in the browser as a JavaScript and jQuery application. Other than the CardDAV server proper, no server is required. It made a good impression during my initial testing, but it mucks with the base64-encoding of contact images in such a way as that other clients (Android, khard) no longer recognize the pictures.

Further reading


The Coronavirus isolation and my speaking more with friends inspired this blog post. Thank you, Christoph, for the heads up.

carddav, addressbook, and cli :: 12 Apr 2020 :: e-mail