Restoring Data from Database Backup

During an upgrade from Nextcloud 13 to 14 I destroyed my installation.

What I still have:

  • A fresh copy of the previous Nextcloud 13 installation (w/o data dir)
  • A database dump of the NC13 sqlite3 database
  • No data dir! (It is on a different disk, and it seems rsync stops at fs boundaries)
  • A year-old full backup (installation + config + data + database from NC12)

I know that the files are lost, but is there a chance to use at least the existing DB,
which still includes Calendar and Contacts data?

I tried a “half” restore procedure (db, no data), which does not work: NC needs the user dirs, appdata dir etc… Using the old data dir and the new database does not seem to work either.

Any ideas?

Thanks,
David

Nextcloud version: 14.0.1.1 (OpenBSD ports)
Operating system and version: OpenBSD 6.4
Apache or nginx version: OpenBSD httpd (chrooted)
PHP version: 7.0

Yes, there is. You can use the script calcardbackup to create *.ics and *.vcf files from the calendar and contacts data in the database. Then you can import those backed up files to a new Nextcloud instance or import them to a client and let them sync the data to a new Nextcloud instance. Though calcardbackup is written for bash, it should also work with openBSDs ksh (from what I read). Otherwise you need to install bash which is also available for openBSD.
IMPORTANT: until release of version 0.8.0 you need to use the testing branch from calcardbackup (version 0.7.2-25 (22.10.2018) or higher)!

  1. create a dummy Nextcloud directory structure for Nextclouds config.php:
    mkdir -p /usr/local/bin/nextcloud-dummy/config
  2. create a file called config.php in that folder and add the dbtype:
    echo "'dbtype' => 'sqlite3'," > /usr/local/bin/nextcloud-dummy/config/config.php
  3. restore the SQLite3 database from your backup in the dummy Nextcloud directory created in step 1:
    sqlite3 "/usr/local/bin/nextcloud-dummy/owncloud.db" < "/path/to/nextcloud-sqlite3.bak"
  4. clone calcardbackup:
    git clone https://github.com/BernieO/calcardbackup
  5. enter the repository directory:
    cd calcardbackup
  6. switch to testing branch (this is only necessary until version 0.8.0 is released):
    git checkout testing
  7. run calcardbackup and give as first argument the path to the dummy Nextcloud directory created in step 1:
    ./calcardbackup /usr/local/bin/nextcloud-dummy
1 Like

Looks good. You’re my hero =)
Found two minor interop issues with the script which I will post into your github.

1 Like

Cool - glad to hear it worked :slight_smile:
Thanks for the github issues. Will have a look soonish.