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.

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

Was this helpful?