Uninstall pg_tde
Mimus records TDE in the data directory. Retain the matching preload, tools and historical keys for recovery, including after dropping the SQL extension. To retire the dependency, migrate into a fresh cluster. Mimus procedure
If you no longer wish to use Transparent Data Encryption (TDE) in your deployment, you can remove the pg_tde extension.
To proceed, you must have one of the following privileges:
- Superuser privileges (to remove the extension globally), or
- Database owner privileges (to remove it from a specific database only)
To uninstall pg_tde, follow the steps below.
Step 1. Remove pg_tde from all databases
Before uninstalling, you must remove the extension from every database where it is loaded. If pg_tde was installed in templates, new databases inherit it. You must drop it from the templates first or future restores/creates will break.
a. Rewrite encrypted tables:
To rewrite an encrypted table back to its default storage method:
b. Remove the extension once all encrypted tables have been rewritten or dropped:
If there are any encrypted objects that were not previously decrypted or deleted, this command will fail and you have to follow the steps above for these objects.
Repeat step 1 for every database in your cluster.
Step 2. Turn off WAL encryption
If you are using WAL encryption, you need to turn it off before you uninstall the pg_tde library:
a. Run:
b. Restart the PostgreSQL cluster to apply the changes:
- On Debian and Ubuntu:
- On RHEL and derivatives:
Step 3. Uninstall the pg_tde shared library
This process removes the extension, but does not decrypt data automatically. Only uninstall the shared library after all encrypted data has been removed or decrypted and WAL encryption has been disabled.
Encrypted WAL pages will not be decrypted, so any postgres cluster needing to read them will need the pg_tde library loaded, and the WAL encryption keys available and in use.
At this point, the shared library is still loaded but no longer active. To fully uninstall pg_tde, complete the steps below.
a. Run SHOW shared_preload_libraries to view the current configuration of preloaded libraries.
For example:
b. Remove pg_tde from the list and apply the new setting using ALTER SYSTEM SET shared_preload_libraries=<your list of libraries>.
For example:
Your list of libraries will most likely be different than the above example. Take care not to remove other required extensions. Only delete pg_tde from the list.
If pg_tde is the only shared library in the list, and it was set via postgresql.conf you cannot disable it using the ALTER SYSTEM SET ... command. Instead:
- Remove the
shared_preload_librariesline frompostgresql.conf - Run
ALTER SYSTEM RESET shared_preload_libraries;
c. Restart the postgresql cluster to apply the changes:
On Debian and Ubuntu:
On RHEL and derivatives:
NoteThe service name may differ depending on your distribution and PostgreSQL version.nod
Step 4. (Optional but recommended) Clean up configuration
At this point it is safe to remove any configuration related to pg_tde from postgresql.conf and postgresql.auto.conf. Look for any configuration parameters prefixed with pg_tde. and remove or comment them out, as needed.
Troubleshooting: PANIC checkpoint not found on restart
This can happen if WAL encryption was not properly disabled before removing pg_tde from shared_preload_libraries, when the PostgreSQL server was not restarted after disabling WAL encryption (see step 3.c).
You might see this when restarting the PostgreSQL cluster:
This error means PostgreSQL is trying to read encrypted WAL without pg_tde loaded.
To resolve it follow these steps:
- Re-add
pg_tdetoshared_preload_libraries - Restart the PostgreSQL cluster
- Follow the instructions for turning off WAL encryption before uninstalling the shared library again
Two restarts are required to uninstall properly if WAL encryption was enabled:
- First to disable WAL encryption
- Second to remove the
pg_tdelibrary