Backups and migrations
The school operator owns backup and restore. YearRoll does not ship a hosted backup service, and nothing in the app writes a backup to a vendor on a timer.
Migrations on startup
Section titled “Migrations on startup”On startup the app checks its migration journal against the SQL files it was built with. In Docker, that check runs before the server listens. A failed file or a checksum mismatch stops the container.
After the process is listening, confirm the journal with:
curl -fsS http://127.0.0.1:3456/api/v1/healthmigrations is applied when the journal matches. pending, mismatch, and error are HTTP 503. See API. Do not send users to an instance whose health check is failing.
Apply the same files the image expects. Do not edit a migration that has already been applied to a school database. A checksum change is a mismatch, and the instance will stay unhealthy until the file and the journal agree.
Back up PostgreSQL
Section titled “Back up PostgreSQL”Take a logical dump of the school database from a machine that can reach it. Custom format keeps the dump restorable with pg_restore:
umask 077pg_dump --format=custom --no-owner --no-acl --file yearroll.dump "$DATABASE_URL"pg_restore --list yearroll.dump >/dev/nullpg_restore --list only reads the file. It does not connect. Store the dump on an encrypted disk the school controls.
If Postgres is the Compose service, you can also dump from the host while the 5432 port is published, using the host form of DATABASE_URL in .env.example. Stop publishing that port on a server that is reachable from the internet.
Never restore onto the live database
Section titled “Never restore onto the live database”Do not point a restore at the database in DATABASE_URL. A restore goes to a different server or a local database you can throw away.
Confirm the target host is not the live host before you restore. The application repository includes a check that compares the two URLs and does not print them:
SOURCE_DATABASE_URL="$DATABASE_URL" \RESTORE_DATABASE_URL="$RESTORE_DATABASE_URL" \npx tsx src/db/check-restore-target.tsRun that from a checkout of yearroll, with RESTORE_DATABASE_URL set to the empty target. Exit 0 means the hosts differ. Exit 1 means it refused, because the hosts match or a host could not be read.
Only then:
pg_restore --no-owner --no-acl --clean --if-exists \ --dbname "$RESTORE_DATABASE_URL" \ yearroll.dumpCheck the restored copy. Leave the running app on the original DATABASE_URL until you have decided to cut over, and change that variable only as a deliberate step. Deleting or overwriting the live database is not a drill.
Next: Licensing and extensions.