Contacts recovery

Hi everyone! I’ve been running NC 14 on my server and syncing, among other things, my contacts onto it, using DAVdroid, plus having the nextcloud android client do the daily backup. Now, the issue is that the nextcloud instance got damaged during an update and after multiple failed recovery attempts I’ve given up and did a fresh install of nextcloud 16.

After so much as opening DAVdroid on my phone it promptly purged all locally stored contacts marked with my previous nextcloud account.

I have access to the (roughly 2.5MB in size) backup VCF files, along with a database backup and all files from the previous install.

The backup VCFs fail to import in android, as well as in evolution on my Linux desktop.

Any tips or pointers would be greatly appreciated since now I’m 100% contacts-free x.x


I had a similar problem. In my experience, Contacts has troubles when importing a big contact file. If you can split it in smaller chunks (maybe importing to Thunderbird - Lightning and exporting in several files), maybe you’ll be able to revert your contacts.

I’ve tried importing the vCard file into Thunderbird to no avail unfortunately. The issue seems to be down to the file’s format, android contacts reject the file due to it being an incompatible format as well.

Where have you create the backup? If you’ve created it using the Nextcloud contacts app, I would recommend to try to imported it the same way.

I‘d try to split the file. Since a vcf-file is just single vCards stuck together one after the other, this is very easy:

  1. Open the file in a text editor
  2. split it anywhere between the lines END:VCARD and BEGIN:VCARD

Another approach is to verify the vcf-file with sabredav.

If that doesn’t help, you could restore the database from your backup and export the addressbooks with the script calcardbackup:

Have a look at the section „does this also work with a broken instance“ in the Readme of the github-repository.


Oh mighty cool, thank you! I shall try to use this, my plaintext editor didn’t like the vCard file, thinking it’s probably binary, so most likely the file is just fuc…ahem…corrupted.

Update: VIm opened the file fine, the VCF itself seems to be encrypted.

I haven’t yet come around to trying the backup script.

Any nextcloud for android devs who could shine some light on the encryption?

It’s the server-side encryption. If you look on the client it should be unencrypted. If it is on the server, the easiest is to go back and restore the last working backup.

Unfortunately the server is long gone and since the contacts are backed up as hidden files, they’re not synced locally onto my PC. Is there a way to recover the encryption keys?

In your old setup, in the user directories on the server, there should be the encryption keys.

The thing about this server-side encryption is that it was designed for external storage, but it is used by most on a local storage where it does not provide the same level of protection. And you have to be careful to have good backups so you don’t end up with unusable files.

1 Like

I’m not using the encryption module on my new instance anymore as the entire server is on a LUKS encrypted drive to prevent local access, while HTTPS takes care of en-route access. I’ll try to decrypt the files and report back.

Cheers mate, appreciate the help!

1 Like

OK so.

Gave up trying to decrypt the files, there’s keys all over the place, no IVs, headache trying to piece the stuff together. Calcardbackup, as suggested by @Bernie_O, worked a treat! Kudos!


I think probably the android-client encrypted your vcf-backup file.

Anyway - glad to hear you could recover your contacts with the help of my script :slight_smile: