# 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`.

{% hint style="danger" %}
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!
{% endhint %}

{% tabs %}
{% tab title="Linux" %}

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

{% endtab %}

{% tab title="MacOS" %}

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

{% endtab %}
{% endtabs %}

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.weap.io/database-backups/how-to-decrypt-a-database-backup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
