Back up an instance
A QuizDock instance keeps its data in three places: the PostgreSQL database, the media folder and the templates folder. A backup takes all three at the same moment, with the configuration.
What to keep
Section titled “What to keep”| Data | Where it lives | In ./quizdock backup |
|---|---|---|
| Accounts, quizzes, settings changed in the administration, archived results, audit | PostgreSQL | Yes, database.sql |
| Keycloak accounts and configuration (full setup) | PostgreSQL, database keycloak |
Yes, keycloak.sql |
| Uploaded images, videos, sounds | MEDIA_DIR (/data/media) |
Yes, media/ |
| Templates folder | STORE_DIR (/data/store) |
Yes, store/ |
| Configuration | .env |
Yes, env |
| Your logo and stylesheet | The branding/ folder you mount |
No: keep a copy yourself |
| The live state of games in progress | Redis | No: it lasts as long as a game |
The media and the templates are files, not rows: a database without the matching media folder shows quizzes with missing images. Keep the three together.
Take a backup
Section titled “Take a backup”On the server, in the instance’s folder:
./quizdock backupOr into a folder of your choice:
./quizdock backup /mnt/backups/quizdock-before-eventWhat it does:
- Dumps the QuizDock database with
pg_dump --clean --if-existsintodatabase.sql, and in the full setup the Keycloak database intokeycloak.sql. The instance keeps running: the dump is consistent on its own. - Copies the media and the templates out of the application container (
media/,store/). - Copies
.envasenv. - Prints the size of the backup.
The default folder is ./backups/quizdock-YYYYMMDD-HHMMSS/, or under QUIZDOCK_BACKUP_DIR when it is set. Files are created readable by their owner only.
Media uploaded while the backup runs may be missing from it. Take backups when no one is editing, for example at night.
Schedule it
Section titled “Schedule it”./quizdock backup does not schedule itself and keeps every backup. With cron, on the server, in the crontab of a user allowed to use Docker, for example every night at 03:00:
0 3 * * * cd /srv/quizdock && ./quizdock backup >> backup.log 2>&1Delete old backups yourself, and copy them off the server: a backup on the same disk does not survive the disk.
Before an upgrade
Section titled “Before an upgrade”./quizdock upgrade takes a backup first, by itself. See Upgrade.
Without the script
Section titled “Without the script”The same backup by hand, in Compose, on the server, in the instance’s folder (user and database as in .env):
docker compose -f docker-compose.prod.yml exec -T postgres pg_dump -U quizdock --clean --if-exists quizdock > database.sqldocker compose -f docker-compose.prod.yml cp quizdock:/data/media ./mediadocker compose -f docker-compose.prod.yml cp quizdock:/data/store ./storecp .env envThe application image has no shell and no tar: docker compose cp copies the folders out of it.