-
Notifications
You must be signed in to change notification settings - Fork 0
Restoring database
This page explains how to restore the database if stored data is corrupted or lost.
Once a day, at 2 a.m. UTC, a database backup is made.
It could be found in backend/db-backup/
on local storage, or in db-backup/
on backend-cron container.
All backups are named according to the following convention: backup_YYYY_MM_DD_HH_mm_SS.sql
.
Where:
- YYYY represents the 4-digit year (e.g., 2024).
- MM represents the 2-digit month (e.g., 09 for September).
- DD represents the 2-digit day of the month (e.g., 13 for the 13th day).
- HH represents the 2-digit hour in 24-hour format (e.g., 15 for 3 PM).
- mm represents the 2-digit minute (e.g., 45 for 45 minutes past the hour).
- SS represents the 2-digit second (e.g., 30 for 30 seconds past the minute).
Note: The time used in the filename follows the Coordinated Universal Time (UTC) standard.
A file containing the database structure must exist on local storage at the following path: backend/db-init/database-structure.sql
.
There are two methods to restore the database. The first one is easier and initializes a new database with the saved data. The second one is more advanced and uses a bash script to import saved data in the database.
In both cases, you first need to shut down the containers.
Shut down all containers using the following command at the root of the project:
docker compose down -v
From local storage, move the most recent database backup to backend/db-init/database-structure.sql
.
Then run the containers using the following command:
docker compose up
Run the containers using the following command:
docker compose up
Enter the backend-cron container shell using the command:
docker exec -it backend-cron /bin/bash
Call restore-db.sh
script on command line:
./usr/local/bin/restore-db.sh
After restoring the database, you might want to check that data has correctly been restored.
Open your web browser and navigate to http://localhost:8080
to open phpMyAdmin.
Once logged in, select backend-database
from the left sidebar to view the tables and verify that the data has been restored.