[Help] Problems in exporting large contacts file


I want to export my contacts via a script for periodic backups. However there is a problem with downloading my big addressbook (which is ~35mb)

when trying to download via script

  • cannot download it with curl
  • wget reports internal server error

when trying to download manually using the web interface

  • firefox results in “File not found” error (after some time trying to download)
  • chromium downloads successfully

I also have a small addressbook, for which the problems above do not occur.

How do I use wget or curl so that it downloads successfully as chromium?

FINAL EDIT: The calcardbackup script also solves the problem by downloading the vcf file directly from the database with the -f option.

Still can’t fix the problem. Any ideas?

The curl command I am using is:
curl -o /filepath/filename.vcf -u [u]:[pw] “[remote_adress]:/remote.php/dav/addressbooks/users/[user]/[addressbook]/?export”

That curl command is correct as long as [addressbook] is the value uri from the table oc_addressbooks (your prefix might be different than oc_).

I suspect a timeout issue of either the webserver or php. You can avoid that by increasing the relevant values of your webserver/php configuration. If you are using nextcloud-snap you need to open an issue for that, since the configuration files of the according webserver and php are not changeable in nextcloud-snap: https://github.com/nextcloud/nextcloud-snap/issues

However, since a addressbook is nothing else than single vCards glued together to one big file, as a workaround you could create a backup of the according addressbook directly from the database. Of course access to the database is needed for that:

  1. find out the id of the addressbook you want to export with:
    mysql -u[dbuser] -p [dbname] -e "SELECT * FROM oc_addressbooks"

  2. get the contacts of the addressbook and save them all together in a file as backup of the addressbook (use the id from step 1 as [ID]) with:
    mysql -u [dbuser] -p [dbname] -sre "SELECT carddata FROM oc_cards where addressbookid=[ID]" > addressbookbackup.vcf


  • I am using the database-table prefix oc_ which is used for standard installations of nextcloud. Your prefix might be different, you can find it in nextclouds
  • [dbuser] and [dbname] can be looked up in nextclouds
  • If you are using nextcloud-snap:
    replace mysql -u [dbuser] -p [dbname] -sre
    with sudo nextcloud.mysql-client
    You don‘t have to look up [dbuser], [dbname] nor the table prefix when using snap.

    replace mysql
    with sudo nextcloud.mysql-client
    all the options are needed. The values can be looked up in nextcloud snaps config.php under /var/snap/nextcloud/current/