Updating Cluster
How to back up, pull a new release tag, migrate the database, and roll back safely if needed.
Always take a manual database backup before upgrading to a new release tag.
Upgrade steps
-
Take a manual backup as the database owner (never with
--enable-row-security):docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -Fc "$POSTGRES_DB"' > cluster-$(date +%F-%H%M).dumpCopy the
.dumpfile off the server. -
Note the current tag in case you need to roll back:
git describe --tags. -
Fetch and check out the new release:
git fetch --tags && git checkout <new-tag>. -
Rebuild images: run
docker compose build. If anyNEXT_PUBLIC_*variable changed, the web image must be rebuilt. -
Apply migrations and restart: run
docker compose up -d. Themigrateservice runs once, updates database roles, applies Prisma migrations, and exits beforeapistarts. If it fails, inspectdocker compose logs migrate. -
Verify health: confirm
https://<your-domain>/api/v1/healthreturnsok, all services indocker compose psarehealthy, and reviewdocker compose logs api --tail 100. -
Run a smoke check with a real account: sign in (with 2FA if enabled), open a KNOW page with an image, play and seek a GROW video lesson, and verify a certificate at
/verify/<code>.
Rolling back
-
Check whether a migration ran:
docker compose logs migrate | grep -i migration. -
If no migration ran: check out the previous tag, run
docker compose build, thendocker compose up -d. -
If a migration ran: the older code may not match the new schema. Restore the backup taken in step 1:
git checkout <previous-tag> docker compose stop api docker compose exec -T postgres sh -c 'pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB" --clean --if-exists' < cluster-<date>.dump docker compose build && docker compose up -d
Any data written between the backup and the restore is lost. Never run storage sweep commands with --apply against a database restored from an older backup than the object storage bucket.