Database
Database and migration failure
Symptom
Manager will not become ready, will not start, or schema commands fail:
/health/ready503 withdatabase: not_configured,database: timeout, ordatabase: unavailable- journal: connection, SSL, password, or migration errors
-migrate/-preflight-migrate/-check-schemaexits non-zero- restore left the Manager unable to authenticate Agents or admins
PostgreSQL is the system of record. SQLite is not the production Manager database.
Likely verified causes
- PostgreSQL down or not reachable at
database.host:database.port(examplelocalhost:5432). - Wrong
database.name/database.user/ password contract. database.ssl_modemismatch. Example defaultrequire. Allowed:disable,require,verify-ca,verify-full.- Enterprise production: password not in YAML; missing systemd credential
database_password($CREDENTIALS_DIRECTORY, expected mount/run/credentials/zwall-manager.servicein strict custody). - Combined exclusive flags:
-migrate,-preflight-migrate,-check-schema,-migration-exec-preflight,-validate-runtime(and-init-dbas migrate alias) — choose one. -init-dbused; it is a deprecated alias for-migrateand logs a warning.- Enterprise: running
-migratefrom a random checkout instead of the admitted release Manager binary. - PostgreSQL major version confusion: Community README states 15+; Enterprise release/test gate is observed as PostgreSQL 16. There is no single published customer major-version matrix.
- Hand-edited
schema_migrationsafter a failed apply. - Restore from a dump that does not include required tables.
Diagnostic commands/endpoints
sudo systemctl status postgresql
sudo systemctl status zwall-manager
sudo journalctl -u zwall-manager -n 200 --no-pager
curl -sS --cacert /etc/zcs/certs/manager.crt \
https://manager.example.com:8443/health/readyReadiness database field: ok | not_configured | timeout | unavailable. Failed checks include database: not_configured, database: timeout, or database: plus HealthCheck() error text.
Manager flags:
# Validate pending plan without applying
/opt/zwall-manager/bin/zwall-manager -config /etc/zwall-manager/manager.yml -preflight-migrate
# Validate recorded schema version and checksums without applying
/opt/zwall-manager/bin/zwall-manager -config /etc/zwall-manager/manager.yml -check-schema
# Forward-only migrate, then exit (do not use as the running service)
/opt/zwall-manager/bin/zwall-manager -config /etc/zwall-manager/manager.yml -migrateCommunity source equivalent uses ./bin/manager -config /etc/zcs/manager.yml with the same flags.
-init-db is deprecated; use -migrate.
Do not combine those flags. The process fatals: Choose only one of -migrate, -preflight-migrate, -check-schema, -migration-exec-preflight, or -validate-runtime.
Scripts (both trees): scripts/backup_db.sh, scripts/restore_db.sh, scripts/full_backup_and_verify.sh. Required env: DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME. Optional PGSSLMODE.
restore_db.sh verifies tables exist after restore:
agentsadminsrulesschema_migrations
What each result means
Scroll sideways to see the full table. Use the arrow keys when focused.
| Result | Meaning |
|---|---|
ready database: not_configured | Manager store nil. Config/bootstrap never opened a database. |
ready database: timeout | Health check exceeded health.readiness_timeout. Server slow or blocked. |
ready database: unavailable | HealthCheck() error (auth, SSL, network, database missing). |
journal SSL / pq: errors with ssl_mode: require | PostgreSQL not offering SSL, or verify mode needs CA (verify-ca / verify-full). |
| Enterprise start reject of YAML password | Production custody rejects literal JWT/database/admin secrets in YAML. |
Community missing JWT_SECRET | Community Manager exits; JWT is env-only. Separate from DB password, but often the same unit file. |
preflight success with pending_versions | History valid; migrate still needed. |
| preflight fatal | Do not apply blindly; fix history/checksums. |
-migrate success then process exit | Expected. Start zwall-manager.service afterwards. |
restore script missing one of agents, admins, rules, schema_migrations | Incomplete dump; do not point the Manager at that database. |
Safe remediation
- Start PostgreSQL. Confirm host/port/name/user.
- Align
ssl_modewith the server. Example production value isrequire, notdisable. - Enterprise: restore
database_passwordvia systemd credentials / admitted custody path — not YAML. Community: operator-managedDB_PASSWORD(Community installer may embed secrets in the unit environment; treat that file as secret-bearing). - Back up before migrate (BACKUP).
- Run
-preflight-migrate, then-migratefrom the admitted Manager binary, then start the service. - If schema is already applied:
-check-schemafor checksums; do not hand-edit migration tables. - Restore: use
scripts/restore_db.shin an isolated environment first. Restore license identity files as a set when licensed (see backup doc). Script existence is not a certified RPO/RTO or zero-downtime contract.
Scripts exist; the certified recovery contract is unresolved. Do not treat dump/restore scripts as a customer RPO/RTO product.
Do-not-do warnings
- Do not combine exclusive migration flags.
- Do not use
-init-dbin new procedures. - Do not run
-migratein the same process you expect to serve HTTP (it exits). - Do not treat a receipt file as permission to skip release verification.
- Do not publish Community “15+” and Enterprise “16” as one certified matrix.
- Do not publish internal 15-minute RPO / 30-minute RTO as a customer SLA.
- Do not put
DB_PASSWORDor backup passphrases on argv or in tickets. - Do not use replication as a backup.
Escalation condition
Escalate when:
- PostgreSQL 16 vs 15 is the suspected incompatibility (owner decision)
- checksums fail on an admitted release binary against a database that
-preflight-migratecannot explain - restore scripts succeed on table presence but Agents/admins cannot authenticate — possible incomplete dump or missing license/identity files; still not a certified runbook
- Enterprise
--manager-database-only/ migration identity flags fail on a verified bundle
Related documentation
- Database preparation
- Database maintenance
- Backup. Restore is not a certified DR product.
- Manager unavailable
- Manager authentication
Edition
SHARED flags and table names. Enterprise uses systemd database_password and verified-release migration identity. Community uses operator env/YAML per Community installer.
Status
SUPPORTED for connect/migrate diagnosis. The restore-contract and PostgreSQL major version remain gaps.