Skip to content

Updating & Migrating

DredBaron edited this page Mar 28, 2026 · 4 revisions

Updating

To update OpenMTG to the latest version:

docker compose pull
docker compose up

Docker compose pull fetches the latest ghcr.io/dredbaron/openmtg:latest image. The docker compose up -d restarts only containers whose image has changed. Database migrations run automatically when the app container starts. The app will not start until the db container passes its health check, so there is no risk of migrations running against an unavailable database.

You do not need to run any migration commands manually.

Config/Data Backup

Two paths need to be backed up regularly. Both are defined in the .env:

  • Database DATA_PATH
cp -r ./data ./data.bak
  • App config CONFIG_PATH
cp -r ./config ./config.bak

Manual Database Backup

Use pg_dump via the running db container for a clean, portable backup:

docker compose exec db pg_dump -U $POSTGRES_USER $POSTGRES_DB > backup.sql

This produces a plain SQL dump in your current directory. Run this with the stack running, pg_dump is safe against live databases.

To create a compressed backup:

docker compose exec db pg_dump -U $POSTGRES_USER $POSTGRES_DB | gzip > backup.sql.gz

Database Restoring from Backup

Note: Restoring overwrites your current data. Make sure you have a backup before proceeding.

  • Bring the stack down
docker compose down
  • Bring up only the database
docker compose up -d db
  • Wait for the container to become healthy, then run the restore
cat backup.sql | docker compose exec -T db psql -U $POSTGRES_USER $POSTGRES_DB
  • If your backup is compressed
gunzip -c backup.sql.gz | docker compose exec -T db psql -U $POSTGRES_USER $POSTGRES_DB
  • Bring the full stack back up
docker compose up -d

Migrating to a new host

  • Back up both DATA_PATH and CONFIG_PATH as described above.
  • Copy the .env file. This contains your DB_PASSWORD and JWT_SECRET which must match the restored data.
  • On the new host, clone the repository, place your .env, restore the database and config, then run docker compose up -d

Note: Changing JWT_SECRET after a move will invalidate all active user sessions. Users will need to log back in, but no data is lost.

Clone this wiki locally