How to decrypt a database backup

If you take MySQL or PostgreSQL backups with encryption enabled, you will have to decrypt the backup before the restore.

Decrypting a backup

For this example, we assume the private key is named my-key.pem and the encrypted backup file is named my-db-backup.sql.gz.

In order to decrypt encrypted backups, you need the private key generated when you enabled the ecryption. If you don't have the key, the content of the backups is lost!

cat my-db-backup.sql.gz | openssl smime -decrypt -inform DER -inkey my-key.pem | gunzip > my-db-backup.sql

After running the command above, a new file my-db-backup.sql will be created with the decrypted database backup.

Last updated