DB restore failed

Hi all!

I currently run NC24.0.2 in docker on a VPC.

I started having an issue with my NC calendar - it would not scroll through months, would not update. That happened right after I created another NC user and shared one of my calendars with them. I decided to restore an older backup (made right before upgrading to 24.0.2 from 24.0.1).

I followed the official guide to make a backup, modified all commands to run in docker. I have several backups by now (data/ config/ and sqldump). Until today I never tested the validity of the backups.

This is the approximate order of things to restore backup:

docker-compose up -d
sudo rm -rf nextcloud-docroot/{data,config}
sudo rsync -Aavx ~/backup/nc-{data,config}_20220623/ nextcloud-docroot/{config,data}/
docker-compose exec nextcloud_db mysql -u nextcloud -pp@$$w0rd -e "DROP DATABASE nextcloud"
docker-compose exec nextcloud_db mysql -u nextcloud -pp@$$w0rd -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
docker exec nextcloud_db mysql -u nextcloud -pp@$$w0rd nextcloud < ~/backup/nc-sqlbkp_20220623.bak

When I restore files/folders, I can launch the instance, but I don’t have my files/calendar etc. Then I try to restore SQL DB, turn off maintenance mode, it dumps a bunch of errors:

Log with a bunch of errors afer restoring DB

My suspicion that the backup is wrong. Could that be possible, if restore ran w/o errors? My DB dump size is about 4.7-4.8 MB. and it increased among the backups, so I assume it is a good dump.

I also have a string in my docker-compose.yml:


Does that affect creating/restoring backups? During backup creation/restoration I used the MYSQL_USER password as you can see above. What could be my problem, and how to properly restore my backup?

P.S. I tried pulling the 24.0.1 docker image and restore there - with no differences in behavior

P.P.S. Another possibly useful line in my docker logs -f nextcloud:

nextcloud | Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused

I noticed that after restoration of my configs and data - I can start the instance and it prompts me to upgrade, but everything crashes specifically after I attempt to restore the DB

I’m not familiar with that env var, but this error is indicating it can’t actually get connected or logged into the database. Make sure the password Nextcloud is using for the database is correct.

Thanks for looking at that!
I tried with an empty password, on restore it prompts me to enter it. I also tried deliberately wrong password and it threw a db access error. So the only way I was able to restore the DB was copying the DB user password.
Now, when do I ever need a ROOT password in my DB? If I understand correctly, on backup and restore I provide the user password, not root. Should I worry about that root password at all? I was simply following a blog on Medium that includes a comprehensive installation of NC in docker.

So on my Reddit thread a user helped me figure this out.
Looks like I needed to initiate a restore process by the mysql user

Problem solved.