Need help backing up my Nextcloud Database

Nextcloud version (eg, 20.0.5): 22.2.3
Operating system and version (eg, Ubuntu 20.04): Unraid 6.9.2
MariaDB version: 10.5.13

The issue you are facing:

I am trying to backup my database, but I’m having a problem. At some point in the last two years, my MariaDB container broke, had to be pulled again, and now it cannot find any databases, even though they exist on the filesystem.

My Nextcloud instance still works and functions perfectly fine. I assume it is still reading from the Nextcloud database within my MariaDB directory, but my MariaDB instance cannot see it. It cannot see the default mysql database either, just “performance_schema”.

As of right now, I cannot create a backup dump of the database as instructed in the Nextcloud documentation, because MariaDB simply cannot see the databases, even though they still exist and are perfectly visible in the directory. I do not know exactly what caused this either. Taking this into account, I have two questions:

Is there a way to fix this strange issue? If not:

If I created a fresh MariaDB container, and placed the Nextcloud Database folder into the new MariaDB databases folder, would I lose any data? Would Nextcloud still be able to use the database the same way it is now?

MariaDB log: https://bin.snopyta.org/?7d477d7475864b77#B6dKoC1bUVJiUEoGmyn4Jf7kM6FxrMbBfzrxibJQwrMi

hi @michaeljones5

I guess you are missing some facts… and look into wrong direction.

in general Nextcloud itself can not read any MariaDB database files (neither Postgres)… the only direct DB file support is SQlite… From your description it sounds like your created new MariaDB container for some reason but your old container hosting the Nextcloud DB is either

  • still working and serving your Nextcloud
  • was never used and your NC uses SQlite

I would recommend your to check the config.php (or the UI if it works)… in https://mycloud.tld/settings/admin/serverinfo you can easily find out which DB is in use e.g. MariaDB in my case

image

then you can choose right steps to connect/backup your database

I think it’s less me looking in the wrong direction, and more just using the incorrect terminology. Perhaps “reading” from a database is the wrong word, but I am 100% sure my Nextcloud instance is still connected to the MariaDB I originally set up two years ago.

Here is a screencap of both my config.php and the database section of my Nextcloud system settings:

mysql
configphp

Here is the only instance of MariaDB (or any MySQL) running on my network:

But when I input sudo mysqld_safe --skip-grant-tables --skip-networking log into the database as the root user, then input show databases;, the only thing that shows up is “information_schema”

Sorry i am not a MariaDB expert.But you can dump the database.

https://mariadb.com/kb/en/mysqldump/

Nextcloud uses a MariaDB/MySQL-DB (see your config.php) and there are all data of your Nextcloud. Then you also can dump the database and the data on the same server:port (socket). Perhaps because of your container/bridging you must use a different ip:port.

hi @michaeljones5 your screenshot shows the container running on 172.17.0.9 but the log you posted above shows 172.17.0.1 for me it sounds like you don’t run the mysqld_safe command from the right place

2021-12-21  4:39:24 4 [Warning] IP address '172.17.0.1' could not be resolved: Name does not resolve

please try to start mysql interactively inside of your container using and check the DB tables and size from there

docker exec -ti <container name> -c 'mysql nextcloud -p$MYSQL_ROOT_PASSWORD'

e.g. if your container ID above is still valid

docker exec -ti 602a9053b35c -c 'mysql nextcloud -p<MYSQL_ROOT_PASSWORD>'