Working with encrypted WAL files

When TDE is enabled, WAL files are encrypted. To read or operate on them directly, you must provide the same decryption mechanism you set up when initializing the cluster.

The examples on this page use the OpenSSL passphrase command from Using a passphrase to illustrate the syntax. Replace it with whichever unwrap command you actually configured for the cluster. See Choosing a key protection mechanism if you haven't chosen a mechanism yet.

Dumping a TDE-encrypted WAL file

To inspect an encrypted WAL file, run pg_waldump with the --data-encryption and --key-file-name=<file> options, using the same encryption configuration you used when initializing the TDE-enabled cluster. Provide the unwrap command either as a command argument or as an environment variable.

Via command argument

pg_waldump --data-encryption --key-file-name=pg_encryption/key.bin \
  --key-unwrap-command='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:<passphrase> -in "%p"'

Via environment variable

export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:<passphrase> -in "%p"'
pg_waldump --data-encryption --key-file-name=pg_encryption/key.bin

This cluster initialization example shows how to export an environment variable. See pg_waldump TDE options for details on each option.

Resetting a corrupt TDE-encrypted WAL file

To reset a corrupt encrypted WAL file, run pg_resetwal, providing the same unwrap command you specified when initializing the cluster, either as a command argument or as an environment variable.

Via command argument

pg_resetwal --key-unwrap-command='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:<passphrase> -in "%p"'

Via environment variable

export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:<passphrase> -in "%p"'
pg_resetwal

See pg_resetwal TDE options for details.


Could this page be better? Report a problem or suggest an addition!