Maintenance and backups
A self-hosted HM Stats installation is a normal production service: back up the database, monitor the containers and update deliberately.
Back up PostgreSQL
From the deployment directory:
cd /opt/hm-stats
docker compose exec -T postgres pg_dump -U "$DB_USERNAME" -d "$DB_DATABASE" > hm-stats-backup.sqlStore the backup outside the server as well.
The database contains your workspace, players, server/season configuration and statistics.
Test restores
A backup is only useful if it can be restored.
Test restoration on a separate PostgreSQL instance before relying on the backup for disaster recovery.
A restore command against an existing target is:
cat hm-stats-backup.sql | docker compose exec -T postgres psql -U "$DB_USERNAME" -d "$DB_DATABASE"Choose the exact restore strategy for your disaster-recovery environment; do not blindly restore over a production database.
Update the server
Back up first.
cd /opt/hm-stats/minecraft-stats-server
git pull
cd /opt/hm-stats
docker compose build app
docker compose up -dThe current container startup runs Laravel migrations automatically.
Check:
docker compose ps
docker compose logs -f appThen verify:
curl -i https://stats.example.com/api/v1/health/readyUpdate the dashboard
cd /opt/hm-stats/minecraft-stats-dashboard
git pull
npm ci
npm run build
sudo rm -rf /srv/hm-stats-dashboard
sudo mkdir -p /srv/hm-stats-dashboard
sudo cp -a dist/. /srv/hm-stats-dashboard/
sudo systemctl reload caddyThe dashboard is static, so replacing dist does not modify PostgreSQL.
Environment and secrets
Keep the deployment environment at:
/opt/hm-stats/.envDo not put it in Git.
Important values include:
APP_KEYDB_PASSWORDOIDC_CLIENT_SECRETAPI_KEY_PEPPER
Changing API_KEY_PEPPER changes how API secrets are verified. Treat it as persistent installation data and preserve it across upgrades.
Container logs
Useful commands:
docker compose logs -f app
docker compose logs -f postgres
docker compose psKeep in mind that logs are operational data. Do not publish raw credentials or session data.
Before a season change
Recommended process:
- Create the new season.
- Activate it.
- Decide whether client API keys should be restricted to the new season.
- Update/rotate client keys as needed.
- Test one player's upload.
- Roll the new configuration to the remaining players.
Before an upgrade
Use this checklist:
- [ ] database backup exists
- [ ] backup restore has been tested recently
- [ ] deployment Git commits are known
- [ ]
.envis safe - [ ] OIDC credentials are known
- [ ] one client key can be rotated if needed
- [ ] health endpoint is monitored