Skip to content

fix(restore): scrub tamanu sync and device identity on every restore - #164

Closed
dannash100 wants to merge 2 commits into
mainfrom
fix/scrub-tamanu-identity
Closed

dannash100 wants to merge 2 commits into
mainfrom
fix/scrub-tamanu-identity

Conversation

@dannash100

@dannash100 dannash100 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

A restored Tamanu database still holds the source server's sync host, sync credentials and device identity, so anything started against a replica (or a copy taken from one) can sync or report status as prod.

  • setup-auth scrubs every database on every restore, before postgres listens: it calls Tamanu's forget_server_identity() (db: TAM-7176: add forget_server_identity() for copied databases tamanu#11378) when the snapshot has it, else deletes the same keys inline.
  • Done in the init script because on a read-only replica the operator's only role can't write.
  • ON_ERROR_STOP so a failed scrub fails the restore. Both branches checked on a Tamanu facility schema with the DB set read-only.

@dannash100

Copy link
Copy Markdown
Contributor Author

🤖 Superseded by #165: replicas never hold the source's key, so the identity only needs clearing where Tamanu actually runs against a restore.

@dannash100 dannash100 closed this Oct 9, 2026
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.

1 participant