Skip to content

Commit a8829b5

Browse files
committed
PG-1832 Document pg_tde's archive and restore commands
Initial quick documentation for the two new CLI commands. We want to improve this futuer in the future plus add a proper guide for how to set up a complete solution.
1 parent d83b36e commit a8829b5

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# Overview of pg_tde CLI tools
22

3-
The `pg_tde` extension introduces new command-line utilities and extends some existing PostgreSQL tools to support encrypted WAL and tables. These include:
3+
The `pg_tde` extension introduces new command-line utilities and extends some existing PostgreSQL tools to support encrypted WAL and tables.
44

5-
* [pg_tde_change_key_provider](../command-line-tools/pg-tde-change-key-provider.md): change encryption key provider for a database
6-
* [pg_waldump](../command-line-tools/pg-waldump.md): inspect and decrypt WAL files
7-
* [pg_checksums](../command-line-tools/pg-tde-checksums.md): verify data checksums (non-encrypted files only)
5+
## New tools
6+
7+
* [pg_tde_change_key_provider](./pg-tde-change-key-provider.md): change encryption key provider for a database
8+
* [pg_tde_archive_decrypt](./pg-tde-archive-decrypt.md): custom archive command for archiving plaintext WAL
9+
* [pg_tde_restore_encrypt](./pg-tde-restore-encrypt.md): custome restore command for making sure restored WAL is encrypted
10+
11+
## Extended tools
12+
13+
* [pg_checksums](./pg-tde-checksums.md): verify data checksums (non-encrypted files only)
14+
* [pg_waldump](./pg-waldump.md): inspect and decrypt WAL files
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# pg_tde_archive_decrypt
2+
3+
Helper command to archive WAL segments in uncrypted form. This is necessary since the WAL encryption keys in the two-key hierarchy (see [Architecture](../architecture/architcture.md)) are specific to the host which generated them and may not be available at the machine which will replay the WAL.
4+
5+
The command wraps your normal archive command and creates a temporary file on a RAM disk, `/dev/shm`, which is then fed as input to your archive command.
6+
7+
This command is often use in conjunction with [pg_tde_restore_encrypt](./pg-tde-restore-encrypt.md).
8+
9+
To use this safely make sure to encrypt the files stored in your WAL archive which is supported by e.g. PgBackRest.
10+
11+
## Examples
12+
13+
Simple example using `cp`:
14+
15+
```ini
16+
archive_command = '/lib/postgresql/17/bin/pg_tde_archive_decrypt %p cp %p /archive/%f'
17+
```
18+
19+
With PgBackRest:
20+
21+
```ini
22+
archive_command = '/lib/postgresql/17/bin/pg_tde_archive_decrypt %p pgbackrest --stanza=tde archive-push %p'
23+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# pg_tde_restore_encrypt
2+
3+
Helper command to take unecrypted segments from the WAL archive and write them to disk in a format which `pg_tde` understands.
4+
5+
The command wraps your normal restore command and has it write the file from the archive to a temporary file on a RAM disk, `/dev/shm` before copying it into PostgreSQL's data directory.
6+
7+
This command is often use in conjunction with [pg_tde_archive_decrypt](./pg-tde-archive-decrypt.md).
8+
9+
## Examples
10+
11+
Simple example using `cp`:
12+
13+
```ini
14+
restore_command = '/lib/postgresql/17/bin/pg_tde_restore_enrypt %f %p cp /archive/%f %p'
15+
```
16+
17+
With PgBackRest add something like the following to `/etc/pgbackrest.conf` or to the command line:
18+
19+
```ini
20+
recovery-option=restore_command=/lib/postgresql/17/bin/pg_tde_restore_encrypt %f %p pgbackrest --stanza=demo archive-get %f "%p"
21+
```

contrib/pg_tde/documentation/mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ nav:
196196
- "pg_tde CLI Tools":
197197
- "Overview": command-line-tools/cli-tools.md
198198
- "pg_tde_change_key_provider": command-line-tools/pg-tde-change-key-provider.md
199-
- "pg_waldump": command-line-tools/pg-waldump.md
199+
- "pg_tde_archive_decrypt": command-line-tools/pg-tde-archive-decrypt.md
200+
- "pg_tde_restore_encrypt": command-line-tools/pg-tde-restore-encrypt.md
200201
- "pg_checksums": command-line-tools/pg-tde-checksums.md
202+
- "pg_waldump": command-line-tools/pg-waldump.md
201203
- "Uninstall pg_tde": how-to/uninstall.md
202204
- "Configure Multi-tenancy": how-to/multi-tenant-setup.md
203205
- "Encryption Enforcement": how-to/enforcement.md

0 commit comments

Comments
 (0)