How Can I Recover Contacts from my Database



Please help us by providing the following info. Before posting please also check the pinned "Known issues" threads and make sure that you're running the latest available version for your oC release:

Steps to reproduce
1. I wanted to rebuild my QNAP Server's storage to support the new Snapshot feature
2. I read that I should backup my ownCloud config and data folders + database
3. I manually backed-up the database via phpMyAdmin
4. I attempted using QNAP's Backup software backup my entire NAS folders (which I thought included the ownCloud folder) to my external 2TB SSD
5. When it's time to restore, I find out some permission issue blocked the backup process of the ownCloud folder to my SSD, so, I don't have the config nor data folder backed-up but I have the Database containing my contacts

Expected behaviour
There should be way to recover my contacts from the database

Actual behaviour
I have no idea how to proceed. I have restored my backed-up database, and I can see all my 424 contacts listed in the "oc_contacts_cards" table. I have also re-created the same ownCloud User account and password, and the same address book name. However, still no contacts listed in the re-created address book. Please could any of you great experts kindly guide me on how to proceed? Thank you very much in advance.

Server configuration
Operating system: QTS 4.2.1
Web server: QNAP TS-470 Pro, 10GB RAM, 4x4TB Seagate ST4000VN000-1H4168 SC46 NAS Storgage, RAID 10 (8TB Total Volume, 15% Reserved for Snapshots), FW QTS v4.2.1 Build 20160601
Database: MySQL Database
PHP version: 5.5.35
ownCloud version (see ownCloud admin page): v8.0.4
Updated from an older ownCloud or fresh install: fresh install
ownCloud log (data/owncloud.log): N/A

Special configuration (external storage, external authentication, reverse proxy, server-side-encryption)
This setup was done with the latest ownCloud package available on the QNAP App Center, v8.0.4 at the moment.

Integrity status for oC9+

N/A I'm on v8.0.4


I would only create a owncloud session to recover your contacts. That means you have a copy of your data, you can play around with it and you don't risk to lose anything. What I would do:

  • Create a new owncloud setup, take the same version as the one you used before (8.0.4)
  • Create all users you had before
  • Put owncloud in maintenance mode
  • Delete all oc_contacts_* tables manually
  • Put all your oc_contacts_* tables from your backup
  • Turn off maintenance mode
  • Login and export contacts.



Thanks for the suggestion. I have created all user accounts as before, but how do I go about putting ownCloud in maintenance mode on my NAS?

Also, I had already imported the ownCloud database before I setup the accounts. How do I ensure ownCloud is still pointing to the right database? Thanks in advance.


In your config/config.php, you can set maintenance-mode to true.

You only import the oc_contacts_*-tables after you created the users.



Really sorry for the extremely late response. Got 'caught up in other issues and kept procrastinating this issue. Either way, I SSHed into my NAS via WinSCP, navigated to the ownCloud/config/ folder, opened the "config.php" file, but there wasn't any "maintenance-mode" line in it. This is what it contained (sensitive parts edited):

$CONFIG = array (
  'instanceid' => '**INSTANCE**',
  'passwordsalt' => '**SALTY**',
  'secret' => '**NO PORN**',
  'trusted_domains' => 
  array (
    0 => '**911.911.1.911**',
  'datadirectory' => '/share/CE_CACHEDEV1_DATA/.qpkg/owncloud/owncloud/data',
  'overwrite.cli.url' => 'https://**911.911.1.911:9111**/owncloud',
  'dbtype' => 'sqlite3',
  'version' => '',
  'installed' => true,
  'loglevel' => 2,

How do I go about putting it into maintenance mode given the above configuration file? Thanks in advance.





Thanks for linking to that site, but what it's saying is the same as what @tflidd stated. However, I don't happen to have that line in my config file. Do I just manually add it without changing anything else?


Yes, you can either add this line or use the occ command line tool as described there.


Alright, I'll continue from there and give a follow up with more information soon.