Back up, restore and migrate
Choose the physical backup path
Use the binaries paired with the source revision. Set PGHOST, PGPORT and PGUSER for a replication-authorized connection. Choose a new BACKUP path on protected storage. Use data checksums on the source, keep the default online page verification enabled and suspend key rotation until the backup finishes. These examples assume the default tablespace layout. With encrypted WAL, r4 excludes cascading physical replication and a restarted standby receiving WAL again from the start of a segment (RISK-36).
Only relations encrypted, WAL always plaintext. With no server WAL key history, the paired ordinary client can stream a plain-format backup:
Encrypted WAL or a source referred to the TDE client. The current switch alone is insufficient if WAL keys were configured previously. For the local example, run the following with read access to the source PGDATA. On a separate backup host securely stage the same pg_tde metadata from the source. Supply the configured provider files, credentials and historical keys there so the server key can be opened. The file provider in the example uses an absolute path; make that path available to the backup and restore accounts. For providers with relative paths, retain their locations relative to the target. Use the plain directory format with streamed WAL:
Read the backup independently
Before starting a restored copy, verify the backup manifest and all its WAL ranges with the matching reader and keys. Keep an independent inventory of the expected encrypted objects and mappings. Reject a backup with a missing mapping even if both online and manifest checks pass.
- On an isolated host, make a working copy of the complete backup owned by the database service account. Keep the original backup intact. Supply the same-major Mimus server, matching preloads and the original provider material. For a file keyring, restore its protected copy separately. If external tablespaces were used, restore their files and mappings.
- Set the restore host’s port and socket directory so your client can only reach the copy. Keep it isolated from replication peers and shared archive destinations. Start the copy with
pg_ctl -D "$RESTORE" -l "$RESTORE_LOG" -w start. For PITR, provision the continuous WAL archive, restore command, recovery target andrecovery.signalbefore the first start. - Connect explicitly to the restored database. For the ledger example, run the following. Expect the committed row
1,100, encryption on table and index, and thetderequirement. For a real backup also compare an out-of-line value, row counts and application invariants with the backup-time baseline.
Compare the heap, indexes and TOAST storage with the saved encryption inventory. Shut down the restored copy cleanly and run pg_tde_checksums --check -D "$RESTORE". Require exit code 0 and Bad checksums of 0.
Installing pg_tde can create recovery dependencies before the first encrypted user table exists. An older backup may cross this activation point during replay. Equip the recovery host before replay and retain the original marker and key metadata. A missing historical key makes the affected backup unreadable even with intact relation files.
Cross-major migration
Use logical dump and restore into a new cluster for a major upgrade. Prepare roles, the target extension and its own keys before loading encrypted objects. Review the dump’s extension entries, table access methods and ownership. Use the target major’s pg_dump -Fc and pg_restore --exit-on-error, then verify constraints, sequences, rows and encryption on the target. Protect the logical archive as plaintext. Keep the source until the checks pass. Physical pg_upgrade of a TDE-marked cluster is outside the 19.0.1 path. Percona backup procedure