Restoring Nextcloud MySQL Database from Backup

Hello Girls and Guys,

I was using Nextcloud Beta 13 with MySQL on my Raspberry Wheezy until i found a Crypto-Miner on my Raspberry.
So i made a Backup with dd and installed everything new.

Now i have a brand new Raspbian system with Nextcloud 12.0.4 (Stable instead of Beta now) and am trying to restore my old Nextcloud Database.

I already extracted the “nextcloud” folder from /var/lib/mysql/nextcloud in my Backup-Image.
After that i copied it to my new Raspbian instance and changed the owner to mysql.
The directory is full of files like ‘oc_***.frm’.

After that i created a new MySql-User with my old Username and also the old password that is saved in the config.php.
But it is still not working and i can’t really find out why.

My config.php:

$CONFIG = array (
  'instanceid' => '***',
  'passwordsalt' => '****',
  'secret' => '*****',
  'trusted_domains' => 
  array (
0 => '',
  'datadirectory' => '/media/festplatte/Nextcloud/data',
  'overwrite.cli.url' => '/',
  'dbtype' => 'mysql',
  'version' => '12.0.4',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_**USERNAME**',
  'dbpassword' => '*****',
  'installed' => true,
  'forcessl' => true,
  'forceSSLforSubdomains' => true,
  'theme' => '',
  'maintenance' => false,
  'appstore.experimental.enabled' => true,
  'loglevel' => 0,
  'trashbin_retention_obligation' => 'auto',
  'updatechecker' => false,
  'updater.server.url' => '',
  '' => 'stable',
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'updater.secret' => '******',

And my Nginx Error Log Looks like this. But i can’t find out why he can’t access the Database:

"message":"An exception occurred while executing 'SELECT * FROM `oc_appconfig`':\n\nSQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_appconfig' doesn't exist in engine",
"userAgent":"Mozilla\/5.0 (Linux) mirall\/2.3.3 (Nextcloud)",

I can’t find a solution for this exception.
If this was the wrong way to do it i can completly delete Nextcloud,Php and MySql again and start again.

I would really appreciate your ideas and your help.
Thanks in regard :wink:


I found out that Nextcloud is not only logging in /var/log/nginx/[debug/error/access].log but also into the data directory. With this information i could understand the errorlogs a bit better.
[Just FYI, my log was under /media/festplatte/Nextcloud/data/nextcloud.log]

After one bottle of wine and a bit luck with Google i found this Stackoverflow-Thread.
Especially this answer:

So after i copied the ib* files from my Backup-Image to my running Raspberry almost everything worked.
I just had to reinstall the APCu cache (like described here: CLICK ) and it worked like a charm.

Hope this can help anyone with the same problem in the future :wink:

Hmm, generally same as downgrading Nextcloud is not supported, also using database from newer version in older one, should be not. Databases get specially upgraded during Nextcloud update according to certain changes. And I guess there can occur several issues, if you use an upgraded database within older instance again.

But good, if it is working in your case, and in case I am wrong, and dumping/restoring generally works to downgrade, then I would be happy to know. Someone else who can assure the one or the other?

1 Like