Backups
What a portal installation keeps where, and what the portal itself does for backups. The portal makes no regular backups of its own: that is the job of whoever runs the servers. How to copy the whole installation, bring it back, take and restore the maintenance backup and set up the monthly restore check is the platform team’s: the admin console’s handbook, Runbooks (the console’s docs/handbooks/platform/en/runbooks.md).
What to keep
Section titled “What to keep”| What | Native installation | Docker | Without it |
|---|---|---|---|
The database, all its schemas (public: the portal’s; platform: the operator’s, owned by the admin console; admin: the console’s own; site: the website’s, where it runs here) |
PostgreSQL, database academy |
volume pgdata |
everything is gone; without platform the operator’s settings, legal texts, prices, sealed provider keys, beta codes, maintenance windows, platform jobs and lab nodes |
| Uploaded files, videos, generated media | /var/lib/academy/storage (STORAGE_DIR) |
volume storage |
courses lose their files and videos |
| The settings | /etc/i3-academy-api.env |
deploy/docker/api.env and deploy/docker/.env |
see below |
| The Git area’s repositories, when it is on | /srv/academy-git |
– | learners’ and trainers’ repositories are gone |
| The erasure log’s copy (ADR 0316) | /var/lib/academy/erasure-log/erasures.jsonl (ERASURE_LOG_FILE) |
volume erasure-log |
people erased after the backup come back with it |
KMS_MASTER_KEY in the settings is the one thing that cannot be made again. Each organisation’s data keys are encrypted with it (ADR 0007); an organisation that brings its own key service (BYOK) needs that service as well. A database without that key can’t be read: keep a copy of the settings file apart from the server and apart from the database backups, readable by as few people as possible. JWT_SECRET and the other secrets can be replaced; everyone then signs in again and connected services are set up again.
What needs no backup: Redis (queues, rate limits and live events; it fills again), the code (it comes from git), the docs site and the nginx sites (the next deploy makes them again), the certificates (certbot gets new ones).
The operator’s tables (platform) and the console’s own (admin) are in the same database and belong to the admin console’s database role, which the portal’s role can’t read (ADR 0449). A dump of public alone is not a backup of the installation. Back up the whole database; the maintenance backup of the console takes each schema with the role that owns it, and the restore check fails a dump that lacks one of them.
Erasures and backups
Section titled “Erasures and backups”A backup still holds the people erased after it was taken. The portal writes every erasure (ids and the time, nothing else) to its erasure log, in the database and in the file above, which the API keeps up to date (at every erasure and every ten minutes) and never shortens; entries older than 13 months go. When the API’s background work starts, it runs again every erasure the file knows and the database doesn’t: a restored person is erased again, with their files, a restored account deleted again, and a restored organisation erased again with its accounting records kept in the archive (ADR 0330; no mails go out again). Failures stay in the file, are tried again every few minutes, and open one ticket per erasure for the platform’s team; the admin console shows where each stands under Data protection → Stuck deletions (the table erasure_replays, ids and codes only), and Retry now there sets them due at once. So keep the file apart from the database and the files, and bring the newest copy you have when you restore: put it back at ERASURE_LOG_FILE (owned by academy-api, mode 600) before the portal’s first start. If the old database still answers, bring the file up to date from it first: node --env-file=/etc/i3-academy-api.env dist/compliance/erasure-log-cli.js save in apps/api of the portal’s runtime (status and replay show and run what is missing).
Backups the deploy makes itself
Section titled “Backups the deploy makes itself”A migration that deletes data names its tables in its header (-- backup before: <table> …, ADR 0233). Before such a migration runs, deploy/update.sh dumps those tables to /var/backups/academy (ACADEMY_BACKUP_DIR in /etc/academy-portal-deploy.env), readable by root only. If the dump fails, the deploy stops before the migration. These dumps are for going back after one migration, not a backup of the installation; the deploy removes those older than 12 months.
The backups of a maintenance window (ADR 0284, /var/backups/academy/maintenance) are the admin console’s (ADR 0458, the console’s ADR 0005): sudo academy-maintenance backup <window id>; its steps are in the console’s handbook. Each schema (public, platform, admin) goes into a dump of its own, taken with the database role that owns it, sealed like the stored files, with the repositories and the files; the newest three stay, none older than 12 months. A restore (sudo academy-maintenance restore <backup id>) runs only while the same window is locked, so nothing was erased since; it first copies what it replaces (before-restore-<time>/), brings the erasure log’s file up to date, puts platform and public back, each in one transaction, and puts them back from the copy if one fails. The console’s own schema admin is put back only with --with-admin (a new server): its log only grows.