Skip to main content

Backup and restore

Two artefacts belong together: the PostgreSQL database and the certificate/key material. The database stores encrypted private keys; without the encryption key a restored database cannot use its certificate rows.

What to back up​

PathContentWhy
PostgreSQL dumpdesired state, revisions, certificates (encrypted), events, accountsEverything the console shows
data/tls/certificate chains and the management certificateServed material and the management listener
data/caddy/verified document, live-state and last-known-goodThe data plane's own serving state
secrets/cert-encryption.keyCertificate encryption keyRequired to decrypt stored private keys
config/controller.envController settings, including the database URLRestore without retyping settings
secrets/postgres_password.txtDatabase passwordMatches the restored dump

The raw WAF record (data/caddy/waf-audit.log) is not needed in a backup and may contain request metadata. Exclude it.

Create a backup​

cd /opt/portavium
install -d -m 0700 backup
STAMP="$(date +%F)"

# 1. logical database dump
docker compose exec -T db pg_dump -U revproxy -Fc revproxy \
> backup/revproxy-${STAMP}.dump

# 2. state, keys and settings
sudo tar -C /opt/portavium -czf backup/revproxy-data-${STAMP}.tgz \
data/tls data/caddy config/controller.env \
secrets/cert-encryption.key secrets/postgres_password.txt
sudo chmod 0600 backup/revproxy-*

Keep both archives together, off the node, encrypted at rest. Test a restore on a separate host before you rely on the backup.

Restore​

Restore on a node with the same image references and the same public addresses, or update PUBLIC_IPV4/PUBLIC_IPV6 in .env and config/controller.env first.

cd /opt/portavium

# 1. stop the stack, keep the volumes
docker compose --env-file .env down

# 2. start only the database
docker compose --env-file .env up -d db

# 3. restore the dump
docker compose exec -T db pg_restore -U revproxy -d revproxy --clean --if-exists \
< backup/<dump>

# 4. restore certificate material, state and settings
sudo tar -C /opt/portavium -xzf backup/<data archive>
sudo chown -R 10001:10001 data/caddy data/tls data/secrets
sudo chown root:10001 secrets secrets/postgres_password.txt secrets/cert-encryption.key
sudo chmod 0640 secrets/postgres_password.txt secrets/cert-encryption.key

# 5. start the stack
docker compose --env-file .env up -d
docker compose --env-file .env ps

Verify the restore​

  1. System shows the expected live revision and running matches verified is yes.
  2. The certificate inventory shows the same versions, and the served leaf fingerprint equals the stored one for names that are served.
  3. The node status endpoint reports ok.
  4. An administrator signs in and, if MFA is enforced, completes the second factor. MFA factors and recovery-code hashes are part of the database, so they survive the restore; a factor enrolled after the dump does not.

What a restore does not do​

  • It does not revoke certificates at the CA.
  • It does not restore the raw WAF record.
  • It does not change files that the deployment owns outside /opt/portavium (firewall, DNS, reverse proxies in front of the node).