Migration 0010: backup and rollback
Docs for PKI Manager 3.17.0 (released 2026-11-24), from main 4d59c30 (30 commits after the release). Page changed after 3.17.0, not in a release yet.
The backend entrypoint migrates on startup. Migration 0010 replaces clusters
with integrations; an older backend cannot use that database. Back up before
deploying the new image. This procedure restores the complete pre-upgrade DB,
including Drizzle’s migration journal; it does not attempt reverse DDL.
What the migration changes
Section titled “What the migration changes”Migration 0010 replaces clusters with integrations, preserving token hashes,
CA bindings, usage and revocation state. Certificate ownership is backfilled in
integration_id; legacy k8s_cluster_id values are retained. Only exclusively
lowercase scep: request histories are reclassified as SCEP. Mixed/empty or
uppercase histories remain Kubernetes. Legacy cluster.* calls and /clusters
links remain compatible; new management uses integration.* and /integrations.
Redeploying v3.14.x against the migrated database fails, because that code expects clusters.
The SCEP gateway is deployed separately.
KMS version for SCEP RA renewal
Section titled “KMS version for SCEP RA renewal”SCEP RA renewal with a retained key requires KMS 5.28.0: 5.24 derives the certificate serial from the public key and therefore reuses it on renewal. The backend refuses serial collisions. 5.28 generates fresh random serials. Do not treat 5.24 as a supported automatic RA-renewal deployment.
Before upgrade
Section titled “Before upgrade”-
Record the exact currently deployed backend/frontend image tags or digests.
-
Stop all gateways, issuer controllers, jobs, and other writers, then stop the frontend/backend. Do not start the upgraded backend yet:
Terminal window docker compose stop frontend backend -
Resolve the actual host path of the backend database. For a named volume, inspect the backend container’s mounts in Docker/Arcane and find the volume mounted at
/app/backend/data.DATABASE_PATHmay override the filename. Run these commands on the Docker host with SQLite 3 installed, substituting the real paths (not the container paths):Terminal window set -eupki_db_path=/actual/host/backend-data/pki.dbpki_backup_path=/secure/backups/pki.before-0010.dbtest -f "$pki_db_path"test ! -e "$pki_backup_path"sqlite3 "$pki_db_path" ".backup '$pki_backup_path'"sqlite3 "$pki_backup_path" 'PRAGMA integrity_check; PRAGMA foreign_key_check;'sqlite3 "$pki_backup_path" "SELECT name FROM sqlite_master WHERE type='table' AND name='clusters';"Check each command succeeded: integrity must be
ok, the FK check must have no rows, andclustersmust exist. Keep the backup outside the application data volume, protect it like the original DB, and retain the matching KMS backup..backupcaptures committed SQLite state including WAL contents; copying only a livepki.dbfile is insufficient. -
Deploy the integration backend/frontend. The entrypoint applies 0010. Verify existing Kubernetes tokens, CA bindings, certificate counts, and revocation state before resuming writers. Deploy the optional SCEP gateway separately. Keep the pre-upgrade images and DB backup until acceptance ends.
Rollback
Section titled “Rollback”Rollback loses DB changes after the backup, including issued certificates, revocations, service tokens and audit rows. Keep all writers stopped throughout; coordinate this restore with your issuance/revocation records and KMS backup. Do not reset or delete the KMS database merely to roll back integration metadata.
-
Stop gateway/controllers/jobs, then
docker compose stop frontend backend. -
Archive the failed-upgrade database and its WAL/SHM files, then restore the pre-upgrade backup while no process has the DB open:
Terminal window # Reuse the actual paths selected above. Choose a new archive directory.pki_archive_dir=/secure/backups/failed-0010mkdir -m 700 "$pki_archive_dir"for pki_suffix in '' '-wal' '-shm'; doif [ -e "$pki_db_path$pki_suffix" ]; thenmv "$pki_db_path$pki_suffix" "$pki_archive_dir/"fidonecp "$pki_backup_path" "$pki_db_path"chown --reference="$pki_archive_dir/$(basename "$pki_db_path")" "$pki_db_path"chmod --reference="$pki_archive_dir/$(basename "$pki_db_path")" "$pki_db_path"sqlite3 "$pki_db_path" 'PRAGMA integrity_check; PRAGMA foreign_key_check;' -
Restore the recorded pre-upgrade backend/frontend image tags/digests in the deployment configuration before starting them, then recreate those services. Starting the integration image would apply 0010 again.
-
Confirm the old Clusters API/UI works and original tokens are accepted before resuming writers. The old backend does not support new integration kinds.
If 0010 already ran without a pre-upgrade backup, this procedure cannot provide a lossless downgrade. Retain the upgraded DB and resolve forward, or arrange a separately validated data conversion; do not simply redeploy an old image.
PKI Manager is a personal project of Oriol Rius, built for his own use. It is not a commercial product. About this project