PostgreSQL Percona TDE

Hello all,

I have a question regarding TDE funcionality.

Currently, I have a running cluster with TDE connected to hashicorp Vault. In case the vault became unreachable and PostgreSQL shutdown it wont startup. There is CLI tool pg_tde_change_key_provider, that should be able to offline change the provider to a file where I do have the backup of key stored in Vault. However, once I start the instance pointing to the file it fails because of the size of the key. Is there a way how to exract correct TDE readable key or any other way how to start the instance when I have the key in file as well?

Many thanks for any hints.

Hello!

No, currently there’s no way to do this. pg_tde_change_key_provider is meant to change the settings of the key provider - for example if the Vault server’s address changed after taking the backup, or while a server was offline, not to point an existing configuration to a completely different provider type.

Hi,

thanks for your reply!

then in case of vault being unreachable we simply have to accept that risk?

@kase007 Correct. This is why it is important to have your KMS in a highly-available configuration, and ensure you are taking backups of your KMS. Vault/openBao fully support multiple nodes for HA, and have native backup/restore snapshot commands.

Hi,

thanks for reply!

I understand. We have Hashicorp in HA of 5 nodes with regulars backups. The problem is that the PostgreSQL instance is connecting to a single endpoint from where it is routed to primary vault. We had a scenario where the certificate expired and the Instance therefore could not connect to the vault. If the Instance would be restarted, it wont start up until the certificate is extended. I am just afraid as this instance is for very critical project across the Europe and US. With the expired cert the backups were not possible to be made. Is there a solution at least to make the backups?

Hi kase007,

Whether a backup can still be taken depends on the backup method and encryption configuration. For example, the documented pg_tde_basebackup -E workflow requires access to the server key, so a Vault TLS failure can prevent that operation.

Could you please share:

  • PostgreSQL and pg_tde versions.

  • Backup tool/version and the command being used, with credentials removed. Is that pgbackrest or…?

  • The complete backup error.

  • Whether WAL encryption is enabled.

  • Whether the expired certificate belongs to the load balancer/proxy or Vault itself.

A consistent storage snapshot may provide an emergency way to preserve the encrypted database without retrieving keys. However, it must capture the complete PostgreSQL cluster, including pg_tde metadata, WAL, and all tablespaces, with simultaneous snapshots where multiple volumes are involved. A normal file copy of a running database is not sufficient.

We are looking forward to hearing back from you.

Warm regards,

N