Upgrading
Back up the database, select a reviewed version, restart the stack and verify access. Backend migrations run before traffic is served and are forward-only: rolling back a migrated schema requires restoring the pre-upgrade database.
Prepare
Read the release notes between your current and target versions for configuration changes, migrations and supported database versions. Select a release with piping-public-release.json and its digest-pinned installation archive; see Install with Docker.
Work in the installation directory containing .env and docker-compose.yml. Use the same Compose project name and edge profile as the installer. In the commands below, replace <project-name> with that name.
- Record current image references and preserve the deployment environment securely.
- Create the backup directory, then dump PostgreSQL. Enable
pipefailso a failed dump cannot look like a successful compressed backup:
set -o pipefail
umask 077
mkdir -p backups
chmod 700 backups
docker compose --project-name <project-name> --env-file .env --profile edge -f docker-compose.yml exec -T postgres \
sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' \
| gzip > "backups/piping-$(date +%Y%m%d-%H%M).sql.gz"
Keep an off-host copy and test recovery. The cipher key and password pepper are also required recovery material; do not regenerate them during an upgrade.
Apply a release bundle
For operator-managed Compose releases, follow stage → backup → apply with scripts/deploy_release_bundle.py and the README from the selected App version.
The root must contain .env, .images.env and docker-compose.yml. Set PIPING_BACKEND_IMAGE, PIPING_FRONTEND_IMAGE and PIPING_ANSIBLE_RUNNER_IMAGE in .images.env to the target release's image references. Keep the existing project name and use a new private stage beneath ROOT/backups; the backups directory must have mode 0700. Configure trusted SSH host keys for off-host backups; never pass credentials on command lines.
Stage verifies the release and immutable images. Backup stops application writers and seals a fresh custom PostgreSQL dump. Apply checks the unchanged configuration/database and an actual off-host copy; the SQL backup above is useful recovery material, but is not a substitute for the script's sealed backup. This rollout permits migration mode only as a verified no-op, so a release requiring schema changes needs its own authorized migration procedure rather than bypassing a failed guard with compose up.
An interrupted operation is not automatically resumable. Inspect its private journal and keep writers stopped on failure. The final started-awaiting-health phase still requires the runtime checks below. Update separate proxy nodes within the compatible release plan.
Verify
Check service health and /api/v1/health, inspect startup logs for migration errors, then sign in and test inventory and a connection. If a service fails, stop the upgrade and use Troubleshooting.
Roll back
If no new migrations ran, restore the previous complete image references and compatible configuration, then recreate the stack. If migrations ran, do not start the old backend against the migrated database.
For a database restore:
- Stop application services so nothing writes during recovery. Preserve the failed database separately if investigation needs it.
- Start PostgreSQL only and restore into the database specified by your protected environment. The following commands delete and recreate that database; confirm the project and backup before running them.
docker compose --project-name <project-name> --env-file .env --profile edge -f docker-compose.yml down
docker compose --project-name <project-name> --env-file .env --profile edge -f docker-compose.yml up -d postgres
docker compose --project-name <project-name> --env-file .env --profile edge -f docker-compose.yml exec -T postgres sh -c \
'psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d postgres -c "DROP DATABASE IF EXISTS $POSTGRES_DB;"'
docker compose --project-name <project-name> --env-file .env --profile edge -f docker-compose.yml exec -T postgres sh -c \
'psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d postgres -c "CREATE DATABASE $POSTGRES_DB;"'
set -o pipefail
gunzip -c backups/piping-YYYYMMDD-HHMM.sql.gz \
| docker compose --project-name <project-name> --env-file .env --profile edge -f docker-compose.yml exec -T postgres sh -c \
'psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" "$POSTGRES_DB"'
- Only after a successful restore, reinstate previous images, configuration and original encryption material. Start the stack and repeat health, sign-in and connection checks.
Do not schedule unattended upgrades unless your automation verifies backups, migrations, compatible configuration and target behavior. Image rollback alone cannot undo database changes.