In my Nextcloud every day a shell script is generating a backup where all the volumes are safed.
Normally, when I execute my “backup-restore-file.sh” the following is happening:
Delete the running container
Delete the volumes
Replace the docker-compose files with the files from the newest backup
Start this docker-compose file
Stop the new containers
Delete the new volumes and replace it with them from the newest backup
Start the containers
normaly all works and the backup is re-installed successfully.
but recently, when I am starting this “backup-restore” shell file this error shows up:
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] Connection timed out in /var/www/html/lib/private/DB/Connection.php:64
Stack trace:
.
.
.
.
Would be interesting which command is producing this error. Can you identify at which step in the script this error message comes up; what script code is producing this?
Maybe something changed with the docker containers now resulting in that error message, meaning that the compose files need some changes?
The most obvious is, that Nextcloud cannot establish a connection to the database. The big question is only why. Is the error message even longer and probably give some more hints?
the error is produced when the script executes the following command (turns the maintenance-mode off):
docker exec -it docker_app_1 su -s /bin/bash “www-data” -c “php occ maintenance:mode --off”
because this is the first command which wants to change something on the running Nextcloud - but Nextcloud is not running.
this is my script:
#JUST STARTING THE PROCESS IF THERE IS A BACKUP TO RESTORE
cd /var/lib/nextcloud-backup/backup/
lastbackup_1=$(ls -Art tail -n 1)