Restore NCP with just "ncdata" possible?

Hi there, I had a NextcloudPi instance up and running for about a year now.

It was on the latest Nextcloudpi version and Nextcloud version from about two weeks from now ( it must be NCP v1.31.0. and Nextcloud was on 21.0.2.1 Update Channel “Stable” without any Security & setup warnings)

Since then I tried restoring my instance.

What happened to my unlucky self:

I also setup the automatic backup (nc-backup) without compression to a external HDD-drive.
It was configured to update every 7 days and delete the oldest backup after 10 backups were created.
That worked fine for me and I already restored my instance once with such a backup.
For a while now I (unfortunately) did not check if the backup gets created successfully.
So now I got 10 Backup files which differ massively in size and can’t be used to restore my instance because they were somehow not completed, I don’t even know why because the HDD had sufficient space and still has (It is a 5 TB HDD my main data SSD has 500 GB). When connecting the HDD it is shown to me as a “Read-only file system”, so maybe the HDD broke as well… it lacks s.m.a.r.t. capability so I don’t know how to prove it right now.
As luck would have it my SD-Card broke down now, I could recover some of the data on it but most of it is gone.
Luckily my main data was on an external SSD. So I still have the “ncdata” directory from that instance. Besides the nextcloud instance was encrypted with the “Default encryption module”

Long story short I would very much like to know if there is any way to restore my instance just with the “ncdata” directory and if not maybe I can extract the other necessary files from either one of the uncompleted backups or the data I could recover from the sdcard.

Also I got a backup file with the NextCloudPi configuration…

Right now there is a new SDCard in my Pi4B (8 GB RAM) with 128 GB.

  • Installed with the image file from the NextcloudPi webpage with the Raspberry Pi Imager.
  • updated and upgraded debian.
  • NextcloudPi version 1.31.0 and the default settings.
  • Nextcloud updated with the uptater inside Nextcloud (not the NCP updater) to v21.0.3
  • installed “sudo apt-get install imagemagick php-imagick”
  • did perform “ncc db:add-missing-indices”
  • did perform “ncc db:convert-filecache-bigint”
  • set my default phone region in the config.php
    → so now there are “All checks passed.” and no Security & setup warnings anymore and the 21.0.3 version is shown as up to date. I think this is a good start for a restore attempt?

My SSD is now next to it with all my data :pleading_face: but I do not know how to proceed from here.

Could anyone please help me? I searched the web widely, please forgive me if I overlooked some information.

Thanks a lot for your effort and time spent (:

Addendum:
I forgot to mention that I created a full image of the now broken SD-Card ones back in time, I think the data at that time were still located at the SD-Card, I tried that image, I can log in with the user, but the “apt-get update && upgrade” fails with some sort of key error, which is the next thing I do not understand. So somewhere in my files there should be most of the parts for a full recovery of my instance I think and I hope (;

Hi @citizenserious, I don’t use NCpi but in nextcloud there is a file named config.php where you can define datadirectory (the folder where files of nextcloud are stored) find where is your nextcloud folder and go to /…/nextcloud/config/config.php. and edit the line datadirectory by your mount point of your ssd. make sur the right permission is given to your mount point.

edit :
check this link it can help you to restore your NCpi : How to backup and restore a NextCloudPi instance | NextCloudPi Documentation

Hi @Mageunic, thanks for the quick reply and helping me (:
I already read the link (documentation) unfortunately it only describes how to create a backup and restore a completed backup (which I do not have).
I followed your advice and changed the datadirectory to ‘datadirectory’ => ‘/media/data/ncdata’, where my original and mounted “ncdata” is located at the SSD. And rebooted the Pi.
But nothing has changed in nextcloud (user ncp still exists, can’t login to users originally existed, there is no data shown). Isn’t it also a problem that the data was encrypted and I do not have the “ncdatabase” ?
I don’t even know what’s included in a full backup and what parts are needed to restore an instance. With that knowledge at hand I could take a look at the parts out of the original sdcard which I recovered or the 10 uncompleted backup-files I still have, to search for the needle in the haystack. But I don’t even know how the needle looks like :smiley: and where to put it or do with it when I would have found it.

@citizenserious ,I forgot to say to rescan files with this lines :
sudo -u www-data php /..../nextcloud/occ files:scan -all

if you have used encryption but you haven’t a save of database, I am afraid that your data is not recoverable because the database contains the correspondence of the keys with the encrypted files in order to decrypt them when they are downloaded or modified

To restore a basic nextcloud instance, you must recover a backup of your database, a copy of the config.php file, the data in the datadirectory folder (which you already have).

I could recover the (I think undamaged) “var” and “usr” directory.
So there I could find the intact config file"/var/www/nextcloud/config/config.php"
and the “/var/lib/mysql” which must be the database folder right? Since I did not change the default location of it.

I would proceed with the transfer of the config file and database (mysql folder) to my ssd and change the location of the database in the config.php. Am I right?

You helped me quite a way now thank you very much, already owe you a bunch of beer.

@citizenserious yes /var/lib/mysql is the right folder. you have to restore the database on your new installation before ( you can’t change the location of database in config.php, maybe with mysql/mariadb but not sure) . Then change the path of datadirectory by the path of your SSD and launch the files scan : sudo -u www-data php /var/www/nextcloud/occ files:scan -all

So I put the NextcloudPi into maintenance mode and backed up the “/var/www/nextcloud/config/config.php” file and the database at “var/lib/mysql”.
Afterwards I deleted the “config.php” and “mysql” and copied the “config.php” and "“mysql” from my old SD-Card there.
Then I launched the file scan with the line you told me sudo -u www-data php /var/www/nextcloud/occ files:scan -all
I restarted the RaspberryPi and get out of maintenance mode.

I geht this message now when navigating to the Nextcloudpage inside my network:

"Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log."

The NextcloudPi Panel shows me this:

NextCloudPi version v1.37.0
NextCloudPi image NextCloudPi_11-27-20
distribution Debian GNU/Linux 10 \n \l
automount yes
USB devices sda
datadir /media/data/ncdata
data in SD no
data filesystem btrfs
data disk usage 194G/477G
rootfs usage 3.9G/118G
swapfile /var/swap
dbdir /var/lib/mysql
Nextcloud check error
HTTPD service up
PHP service up
MariaDB service down
Redis service up
Postfix service up
internet check ok

Did I do something wrong? Or overlooked something?

Should I have keeped the original “config.php” and only change the database location instead of replacing it with the “old” one (from my SD-Card) ?
The datadir location is correct and the SSD is mounted at that point.
The dbdir at /var/lib/mysql also is correct (with the replaced folder)

The nextcloud.log show this:

{“reqId”:“zT7Axls9gth86OfhnFzs”,“level”:3,“time”:“2020-11-27T23:24:35+00:00”,“remoteAddr”:"",“user”:“ncp”,“app”:“no app in context”,“method”:"",“url”:"–",“message”:{“Exception”:“OCP\AppF$
{“reqId”:“zT7Axls9gth86OfhnFzs”,“level”:3,“time”:“2020-11-27T23:24:35+00:00”,“remoteAddr”:”",“user”:“ncp”,“app”:“no app in context”,“method”:"",“url”:"–",“message”:{“Exception”:“OCP\AppF$
{“reqId”:“aggIm81bCNY0I08O4CYT”,“level”:1,“time”:“2021-07-16T18:07:07+00:00”,“remoteAddr”:”",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::maintenanceEnabled$
{“reqId”:“aggIm81bCNY0I08O4CYT”,“level”:0,“time”:“2021-07-16T18:07:07+00:00”,“remoteAddr”:"",“user”:"–",“app”:“core”,“method”:"",“url”:"–",“message”:“starting upgrade from 20.0.2.2 to 22$
{“reqId”:“aggIm81bCNY0I08O4CYT”,“level”:3,“time”:“2021-07-16T18:07:07+00:00”,“remoteAddr”:”",“user”:"–",“app”:“no app in context”,“method”:"",“url”:"–",“message”:“Updates between multipl$
{“reqId”:“aggIm81bCNY0I08O4CYT”,“level”:3,“time”:“2021-07-16T18:07:07+00:00”,“remoteAddr”:”",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::failure: Exception$
{“reqId”:“aggIm81bCNY0I08O4CYT”,“level”:3,“time”:“2021-07-16T18:07:07+00:00”,“remoteAddr”:"",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::updateEnd: Update $
{“reqId”:“aggIm81bCNY0I08O4CYT”,“level”:1,“time”:“2021-07-16T18:07:07+00:00”,“remoteAddr”:"",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::maintenanceActive:$
{“reqId”:“aggIm81bCNY0I08O4CYT”,“level”:1,“time”:“2021-07-16T18:07:07+00:00”,“remoteAddr”:"",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::resetLogLevel: Res$
{“reqId”:“YPHLqC6F5BEXNXV1RNiPKQAAQw0”,“level”:3,“time”:“2021-07-16T18:10:48+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“index”,“method”:“GET”,“url”:"/index.php/apps/accessibil$
{“reqId”:“fXyVOiBgXiunPsSwXtlu”,“level”:1,“time”:“2021-07-16T18:19:18+00:00”,“remoteAddr”:"",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::maintenanceEnabled$
{“reqId”:“fXyVOiBgXiunPsSwXtlu”,“level”:0,“time”:“2021-07-16T18:19:18+00:00”,“remoteAddr”:"",“user”:"–",“app”:“core”,“method”:"",“url”:"–",“message”:“starting upgrade from 20.0.2.2 to 22$
{“reqId”:“fXyVOiBgXiunPsSwXtlu”,“level”:3,“time”:“2021-07-16T18:19:18+00:00”,“remoteAddr”:”",“user”:"–",“app”:“no app in context”,“method”:"",“url”:"–",“message”:“Updates between multipl$
{“reqId”:“fXyVOiBgXiunPsSwXtlu”,“level”:3,“time”:“2021-07-16T18:19:18+00:00”,“remoteAddr”:”",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::failure: Exception$
{“reqId”:“fXyVOiBgXiunPsSwXtlu”,“level”:3,“time”:“2021-07-16T18:19:18+00:00”,“remoteAddr”:"",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::updateEnd: Update $
{“reqId”:“fXyVOiBgXiunPsSwXtlu”,“level”:1,“time”:“2021-07-16T18:19:18+00:00”,“remoteAddr”:"",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::maintenanceActive:$
{“reqId”:“fXyVOiBgXiunPsSwXtlu”,“level”:1,“time”:“2021-07-16T18:19:18+00:00”,“remoteAddr”:"",“user”:"–",“app”:“updater”,“method”:"",“url”:"–",“message”:"\OC\Updater::resetLogLevel: Res$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:0,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/core/ajax/update.php?reque$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:57+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:58+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:58+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:59+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:42:59+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“updater”,“method”:“GET”,“url”:"/core/ajax/update.php?re$
{“reqId”:“YPHTMewyhWbVGvSpc61QSwAAEAc”,“level”:1,“time”:“2021-07-16T18:43:00+00:00”,“remoteAddr”:“192.168.178.58”,“user”:"–",“app”:“no app in context”,“method”:“GET”,“url”:"/core/ajax/upd$


Output of sudo -u www-data php /var/www/nextcloud/occ files:scan -all :

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurre d in the driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/ne xtcloud/lib/private/DB/Connection.php:85
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1486): OC\DB\Con nection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1014): Doctrine\ DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(226): Doctrine\DBAL\Connecti on->executeQuery(‘SELECT * FROM ...', Array, Array, NULL) #3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(210): OC \DB\Connection->executeQuery('SELECT * FROM …’, Array, Array)
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrin e\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(345): OC\DB\QueryBuilder\QueryBu ilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(110): OC\AppConfig->loadConfigVa lues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(301): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(965): OC\AppConfig->getValue s(false, ‘installed_versi…’)
#9 /var/www/nextcloud/lib/private/Server.php(682): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\Server->OC{closure}(Object(OC\Server))
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OC\Memcache\Fac…’)
#13 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OC\Memcache\Fac…’, false)
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OC\Memcache\Fac…’)
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(177) : OC\AppFramework\Utility\SimpleContainer->get(‘OC\Memcache\Fac…’)
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Obj ect(OC\Server))
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OCP\ICacheFacto…’)
#19 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OCP\ICacheFacto…’, false)
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OCP\ICacheFacto…’)
#21 /var/www/nextcloud/lib/private/Server.php(1031): OC\AppFramework\Utility\Sim pleContainer->get(‘OCP\ICacheFacto…’)
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\Server->OC{closure}(Object(OC\Server))
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OCP\Lock\ILocki…’)
#25 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OCP\Lock\ILocki…’, false)
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OCP\Lock\ILocki…’)
#27 /var/www/nextcloud/lib/private/Server.php(1990): OC\AppFramework\Utility\Sim pleContainer->get(‘OCP\Lock\ILocki…’)
#28 /var/www/nextcloud/lib/private/Files/View.php(119): OC\Server->getLockingPro vider()
#29 /var/www/nextcloud/lib/private/Server.php(430): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\Server->OC{closure}(Object(OC\Server))
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OC\Files\Node\H…’)
#33 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OC\Files\Node\H…’, false)
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OC\Files\Node\H…’)
#35 /var/www/nextcloud/lib/private/Server.php(1353): OC\AppFramework\Utility\Sim pleContainer->get(‘OC\Files\Node\H…’)
#36 /var/www/nextcloud/lib/base.php(588): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1076): OC::init()
#38 /var/www/nextcloud/console.php(49): require_once(’/var/www/nextcl…’)
#39 /var/www/nextcloud/occ(11): require_once(’/var/www/nextcl…’)
#40 {main}

@citizenserious I think there is another proper way to restore your database into maria db

try this line : sudo chown -R mysql:mysql /var/lib/mysql/
restart mariadb and check if maria is up or down

check log of mariadb pls, nextcloud can’t work without database.

have you set the correct permission on your mount point to your ssd for nextcloud ? ( check the user with ls -l . Maybe the user of nextcloud is www-data, maybe other user )

@Mageunic mariadb is up now. I can’t find a log for mariadb though.

The permission at the mount point (/media/data) is “root”
the ncdata (/media/data/ncdata) directory “www-data”
The mysql (/var/lib/mysql) database has “mysql” permission.

NextcloudPi Panel still shows:
|Nextcloud check|error|

and there still is an Internal Server Error

Hi @citizenserious , check if www-data user avec read permission to /media/data and /media
if yes check nextcloud.log files for more details about the internal error.

@Mageunic I did set the “www-data” users permission, so:
drwxr-xr-x 3 www-data www-data for /media
drwxr-xr-x 1 www-data www-data for /media/data
drwxrwx— 1 www-data www-data for /media/data/ncdata

it still shows me the same errors, the log file doesn’t log anything with a timestamp from today, so I reset the location of the logfile back to default (with config.php) to “/var/www/nextcloud/data/nextcloud.log” to exclude permission write problems for the log, but there is still no new entry emerging even after several restarts and maintenance mode changes :pensive:

@citizenserious try this line: sudo -u www-data php /var/www/nextcloud/occ maintenance:repair

which error have you ?

thats the output:

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurre d in the driver: SQLSTATE[HY000] [1045] Access denied for user ‘ncadmin’@‘localh ost’ (using password: YES) in /var/www/nextcloud/lib/private/DB/Connection.php:8 5
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1486): OC\DB\Con nection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1014): Doctrine\ DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(226): Doctrine\DBAL\Connecti on->executeQuery(‘SELECT * FROM ...', Array, Array, NULL) #3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(210): OC \DB\Connection->executeQuery('SELECT * FROM …’, Array, Array)
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrin e\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(345): OC\DB\QueryBuilder\QueryBu ilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(110): OC\AppConfig->loadConfigVa lues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(301): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(965): OC\AppConfig->getValue s(false, ‘installed_versi…’)
#9 /var/www/nextcloud/lib/private/Server.php(682): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\Server->OC{closure}(Object(OC\Server))
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OC\Memcache\Fac…’)
#13 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OC\Memcache\Fac…’, false)
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OC\Memcache\Fac…’)
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(177) : OC\AppFramework\Utility\SimpleContainer->get(‘OC\Memcache\Fac…’)
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Obj ect(OC\Server))
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OCP\ICacheFacto…’)
#19 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OCP\ICacheFacto…’, false)
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OCP\ICacheFacto…’)
#21 /var/www/nextcloud/lib/private/Server.php(1031): OC\AppFramework\Utility\Sim pleContainer->get(‘OCP\ICacheFacto…’)
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\Server->OC{closure}(Object(OC\Server))
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OCP\Lock\ILocki…’)
#25 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OCP\Lock\ILocki…’, false)
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OCP\Lock\ILocki…’)
#27 /var/www/nextcloud/lib/private/Server.php(1990): OC\AppFramework\Utility\Sim pleContainer->get(‘OCP\Lock\ILocki…’)
#28 /var/www/nextcloud/lib/private/Files/View.php(119): OC\Server->getLockingPro vider()
#29 /var/www/nextcloud/lib/private/Server.php(430): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155) : OC\Server->OC{closure}(Object(OC\Server))
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\ AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(P imple\Container))
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122) : Pimple\Container->offsetGet(‘OC\Files\Node\H…’)
#33 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Uti lity\SimpleContainer->query(‘OC\Files\Node\H…’, false)
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query(‘OC\Files\Node\H…’)
#35 /var/www/nextcloud/lib/private/Server.php(1353): OC\AppFramework\Utility\Sim pleContainer->get(‘OC\Files\Node\H…’)
#36 /var/www/nextcloud/lib/base.php(588): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1076): OC::init()
#38 /var/www/nextcloud/console.php(49): require_once(’/var/www/nextcl…’)
#39 /var/www/nextcloud/occ(11): require_once(’/var/www/nextcl…’)

@citizenserious you have a DB connection error… go into config.php and note the information about the database and its user. check if the user of databe exist and password is correct.
sudo mysql -u user -p ( replace user by yours)

check if database can be used by the user :
SHOW databases;

send the outpout of this comand pls

you where right the password in the config.php was wrong, I changed it to the right one I think.
The user for the database by default is “ncadmin”.

MariaDB [(none)]> SHOW databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| nextcloud |
±-------------------+

When executing sudo -u www-data php /var/www/nextcloud/occ maintenance:repair

It shows me this now:

Cannot write into “config” directory!
This can usually be fixed by giving the webserver write access to the config directory

Or, if you prefer to keep config.php file read only, set the option “config_is_read_only” to true in it.
See https://docs.nextcloud.com/server/21/go.php?to=admin-config

So the next problem was that the webserver needed write access… so I changed the permission for the config.php
from
-rwxr-xr-x 1 root root for config.php
to
-rwxr-xr-x 1 www-data www-data for config.php

Then I initiated -u www-data php /var/www/nextcloud/occ maintenance:repair again and it WORKED :heart_eyes: :star_struck: Oh my god, I am so happy right now.
When navigating to my server page it shows me a bunch of app updates now, can I simply install them? I hope it will work afterwards but I will wait for your reply. I don’t understand though why the “www-data” user works even when in the config.php the user for the database is “ncdata”. But if it works I am fine with it :smiley:

1 Like

@citizenserious you can install the updates. there is 2 users, one is linux user ( www-data) used by nginx/apache to access to the filesystem and the other is mysql user for the database. all write/ read /execute permissions is related to linux user ( www-data).

www-data is the owner of nextcloud folder ( and subfolder) ? if not , please change it to www-data

sudo chown -R www-data:www-data /var/www/nextcloud/

@Mageunic Just awesome, I can login, everything seems to be working except for my files I got the Error “Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files.”

Anyway you are a absolute genius! Thank you so so very much.

The last issue must also be possible to solve somehow.
If everything works then, I will write a summary how to proceed when manually trying to restore an instance, I am sure someone else will encounter this problem. I would be very happy if you are willing to proofread that summary then (:

The /var/www/nextcloud/ and its subfolder are owned by www-data.

1 Like

@citizenserious I suggest you to decrypt your data and make a backup of it :

sudo -u www-data php /var/www/nextcloud/ encryption:decrypt-all

1 Like

@Mageunic What is odd is that when I reboot my instance, the password for the database in the config.php changes so I have to change it again and initiate maintenance:repair again.
Then it work’s again, until a restart.

When executing sudo -u www-data php /var/www/nextcloud/ encryption:decrypt-all nothing happens.

@citizenserious this is strange maybe nextcloudpi software ( not nextcloud) change the password, i think you have too change the user database password to have no issue.

sudo mysql -u root -p
SET PASSWORD FOR ‘ncadmin’@localhost = PASSWORD(“newpassword”);
( change newpassword by yours)
EXIT;

my bad, there is a little mistake in my line : sudo -u www-data php /var/www/nextcloud/occ encryption:decrypt-all

I forgot to put occ at the end of the path