Skip to content

feat(tamanu): print the config key path for backup defs - #830

Open
dannash100 wants to merge 4 commits into
mainfrom
feat/tamanu-config-key-path
Open

feat(tamanu): print the config key path for backup defs#830
dannash100 wants to merge 4 commits into
mainfrom
feat/tamanu-config-key-path

Conversation

@dannash100

Copy link
Copy Markdown
Contributor

Tamanu 2.60+ encrypts every local_system_secrets value (the settings PSK and so every secret setting, the device key, a facility's sync password) with a per-server key. No backup captures that key today, so a database restored onto another host reads none of them: a clone comes up with its sync user locked out, and a rebuilt host loses its secrets outright.

bestool tamanu config-key-path prints the resolved crypto.keyFile, so a backup def can name it as path_command and capture the key with the database it belongs to.

  • Resolves relative paths against the server package dir, as the server does; absolute passes through; no package dir is an error rather than a guess.
  • No database needed: server kind comes from the config alone.
  • Container installs mount the key as a podman secret and have no path to print; those are covered by backing up podman's secret store instead.

@dannash100
dannash100 force-pushed the feat/tamanu-config-key-path branch from 39b640d to c113992 Compare August 18, 2026 01:08
@passcod

passcod commented Aug 18, 2026

Copy link
Copy Markdown
Member

Hmmm I would prefer a special "tamanu secret key" backup method which does the right thing per platform. That way when seedling lands it can start also doing the right thing, and it might be able to be clever enough in future to convert a windows secret to a linux secret to a seedling secret.

Comment thread .workhorse/specs/canopy/backup.md Outdated

Where the key lives is a property of the install, not of the definition, so the method resolves it rather than having an operator name a path per host.
A bare-metal or Windows install points `crypto.keyFile` at a file, relative paths resolving against the server package directory as they do for the server itself.
A containerised install takes the key as a podman secret and has no server-side path, so podman's secret store is captured whole instead — the store holds every secret on the host, and podman owns its layout.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, hold on, couldn't bestool ask the podman API for the secret value and back that up as a file? There might be unrelated secrets in the full store, or even values that are genuinely proper to the host and shouldn't be restored. And a single secret value is migratable, while a podman store as a blob isn't.

Comment thread .workhorse/specs/canopy/backup.md Outdated
It is not offered as a rollback point: re-capturing a key costs nothing, so there is nothing a hold would buy.

A restore lays the captured shape back where this host keeps it, keeping any key it displaces beside it.
Restoring one shape onto a host that wants the other is refused rather than converted: turning a Windows key file into a podman secret is a real transformation, and a half-right one leaves a server that starts and reads none of its secrets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restoring one shape into another is a property I explicitly said we wanted, though?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants