Skip to content

Keys and backups

Three things matter, and only the first is in the database:

  • The Postgres database holds users, settings, history, and the encrypted credentials.
  • KELPIE_SECRET_KEY encrypts git, registry, forge, notification, and OIDC credentials. Without it, those credentials can’t be read and have to be entered again.
  • KELPIE_AGE_KEY decrypts secrets.env files. Without it, stacks with secrets can’t be deployed, and the secrets in git can only be recovered with another recipient’s key. Keep a copy outside the cluster, or list a second age key (kept offline) in .sops.yaml.

Git checkouts don’t need a backup. Kelpie recreates them from the remotes.

The agent token can be replaced at any time. Swarm secrets can’t be changed in place, so to replace one, create it under a new name and set that as the secret’s name: in the stack file:

secrets:
kelpie_agent_token:
external: true
name: kelpie_agent_token_2

The services keep reading it from the same path, so nothing else changes. Redeploy the stack.

Back up the database and keep copies of the two keys, the secret-key and age-key files from the install. With the example stack file, Postgres runs on a manager. On that node:

Terminal window
docker exec "$(docker ps -q -f name=kelpie_postgres)" \
pg_dump -U kelpie -Fc kelpie > kelpie-$(date +%F).dump

Stop the server, restore, and start it again:

Terminal window
docker service scale kelpie_server=0
docker exec -i "$(docker ps -q -f name=kelpie_postgres)" \
pg_restore -U kelpie -d postgres --clean --if-exists --create \
< kelpie-2026-11-24.dump
docker service scale kelpie_server=1

--create drops the database and creates it again from the backup. Restoring into the existing database instead would leave behind tables that a newer version added, and the next upgrade would fail on them.

A restored database needs the KELPIE_SECRET_KEY it was created with.