Production readiness and recovery

Use the same application revision, frozen parcel CRS, PostgreSQL/PostGIS versions and media configuration for rehearsal and recovery. Record the revision, backup timestamp, size, last committed workflow event and achieved recovery time. The operator sets the recovery time and data-loss objectives for the installation.

Traffic and monitoring

Dokku's web startup and readiness checks request /readyz/. A 200 response requires PostGIS and the application's expected migration heads. An unavailable database or pending schema returns 503. Keep /healthz/ as the independent process liveness check. Configure external monitoring to request the HTTPS readiness URL with the deployment hostname, alert on repeated non-200 responses or timeouts, and check request latency and server errors separately. Verify the actual proxy and alert destination in staging by withholding the database from an isolated release and observing both traffic withdrawal and the alert. Restore access and observe recovery before promotion.

Before deployment

  1. Quiesce all writers, including background jobs, imports and media writers. Finish or abort in-flight requests. Keep writes paused until both archives and the verification inventory are complete.
  2. Use a private backup directory and a configured PostgreSQL service or protected credential file. Record required database owner/grantee roles, memberships and extensions separately. Provision those roles from trusted infrastructure configuration on the recovery server. Preserve object ownership and grants during restore.
  3. With the source database selected by PGDATABASE and the configured media directory in MEDIA_ROOT, run the following in the private backup directory:

sh umask 077 pg_dump --format=custom --file=database.dump tar -C "$MEDIA_ROOT" -cf media.tar . sha256sum database.dump media.tar > SHA256SUMS

  1. Retain a protected off-host copy. Record parcel version counts and exact geometry checksums (ordered parcel IDs and ST_AsEWKB(geometry)), frozen SRID, draft/event counts, selection receipt/item counts and linked event counts. Inventory media by relative path and hash and verify that database-referenced upload previews exist.

Restore rehearsal and rollback

  1. Start an isolated instance, create the recorded roles and an empty database, and select that database explicitly. Use a new empty media directory. Confirm both targets before loading data.
  2. Verify and restore the matched pair:

sh sha256sum --check SHA256SUMS pg_restore --exit-on-error --single-transaction --dbname="$RECOVERY_DATABASE" database.dump tar -C "$RECOVERY_MEDIA_ROOT" -xf media.tar

  1. Connect the matching application revision to the restored database and media. Compare the inventory, run manage.py migrate --check, and verify /readyz/, restricted access, parcel history and an upload preview as an authorized user. Rehearse the intended forward migration on a copy. Record elapsed time and the interval between the snapshot and any writes accepted after it.
  2. Migration 0028 refuses reversal once selection receipts exist. If the release must be rolled back, pause writes, preserve the failed environment, restore the pre-deployment database/media pair and matching code, verify the inventory and readiness, then switch traffic. Identify and reconcile any work accepted after the snapshot before reopening writes. Do not fake migration records or delete receipts to make reversal succeed.

Concurrent edits

The browser submits the revision displayed when the edit form opened. A stale save returns HTTP 409 and keeps the submitted values in that tab. Open Review current draft and reapply the desired changes in the new tab. For the parcel draft API, GET the draft detail and include its opaque draft_revision field alongside payload in PATCH. On 409, retain the attempted patch, retrieve the latest detail and reconcile before submitting again.