# Aiven

How to back up and restore Aiven managed databases via SimpleBackups.

Aiven is a managed database platform that supports MySQL, PostgreSQL, and other database engines. SimpleBackups can connect to your Aiven database either automatically via the Aiven API — which discovers your databases without manual configuration — or manually using a connection string. Both methods work for MySQL and PostgreSQL.

## Automatic setup

In this section, you will generate an Aiven API token and connect your Aiven project to SimpleBackups so that databases are discovered automatically.

### Step 1: Obtain Aiven API credentials

You can use either a personal token or an application token.

**Option A: Create a personal token**

1. Go to [https://console.aiven.io/profile/tokens](https://console.aiven.io/profile/tokens).
2. Click **Generate token**.
3. Select a session duration or leave it empty, then click **Generate**.
4. Copy the generated token to a safe location.

![Aiven personal token generation screen](https://simplebackups.com/docs/docs-assets/media-helpkit-co/227e5c0d57669502b0ba.png)

**Option B: Create an application token**

1. Go to the **Admin** section from the top navigation bar.
2. Select **Application users** from the left sidebar.
3. Click **Create application user** and choose a name.

![Aiven application user creation screen](https://simplebackups.com/docs/docs-assets/media-helpkit-co/fdc3b5b14640923e5885.png)

4. From **Actions**, choose **View profile**.
5. Under **Authentication tokens**, click **Generate token**.
6. Select a session duration or leave it empty, then click **Generate**.
7. Copy the generated token to a safe location.
8. Select **Permissions** from the left sidebar.
9. Click **Grant permissions**, then **Grant to users**.
10. Select the application user you just created and assign the **Read Only** role under **Project Roles**.

![Aiven permissions screen showing Read Only role assignment](https://simplebackups.com/docs/docs-assets/media-helpkit-co/7b4c568e9ce2e7a67f76.png)

### Step 2: Get the project name

1. From the navigation bar, go to **Projects**.
2. Select **View all projects**.
3. Choose the project that contains the database you want to back up.
4. From the menu, choose **Settings** and copy the **Project Name**.

![Aiven project settings screen showing project name](https://simplebackups.com/docs/docs-assets/media-helpkit-co/694f490cc83525bbd55f.png)

### Step 3: Connect Aiven to SimpleBackups

1. Go to the [database backup page](https://my.simplebackups.com/backup/create?type=db) and click **Add** in the **Connect your DBaaS Provider** section.
2. Select **Aiven** from the **Provider** dropdown, enter a name for your Aiven account, paste the token and project name from the previous steps, then click **Save provider**.

![Aiven provider connection form in SimpleBackups](https://simplebackups.com/docs/docs-assets/media-helpkit-co/9c9b59b6177e5a497836.png)

![Aiven provider saved confirmation](https://simplebackups.com/docs/docs-assets/media-helpkit-co/164da0e101ac2e599c05.png)

3. Select the managed database you want to back up.
4. Click **Load**.

![Database selection screen in SimpleBackups](https://simplebackups.com/docs/docs-assets/media-helpkit-co/97b938e04a9e611e89f0.png)

### Step 4: Validate and activate

Click **Validate connection** to confirm that SimpleBackups can reach your database. Once validated, configure your schedule and activate the backup.

## Manual setup

Use this approach if you prefer to supply connection credentials directly rather than through the Aiven API. The steps are the same for MySQL and PostgreSQL — only the connection string format and the database type you select in SimpleBackups differ.

### Step 1: Copy your connection string

1. Log in to your Aiven console.
2. Navigate to the database service you want to back up.
3. Click **Overview**, then **Connect**, or refer to **Connection Details** on the dashboard.
4. Copy the connection string and replace the `****` placeholder with your actual password.

For MySQL, your connection string will look like this:

![Aiven MySQL connection details screen showing the connection string](https://simplebackups.com/docs/docs-assets/media-helpkit-co/e779c247a86d14587f33.png)

For PostgreSQL, your connection string will look like this:

![Aiven PostgreSQL connection details screen showing the connection string](https://simplebackups.com/docs/docs-assets/media-helpkit-co/8f4f6ee31f4141fe11b5.png)

You can also find the **Service URI** in the **Connection information** section, along with a downloadable **CA certificate**.

![Aiven connection information screen showing Service URI](https://simplebackups.com/docs/docs-assets/media-helpkit-co/a5967e56df9eb61ff1e6.png)

### Step 2: Whitelist SimpleBackups IP addresses

**Info:**
If your database is behind a firewall, you need to allowlist SimpleBackups before it can connect.

1. In the Aiven console service overview, scroll down to the **Allowed IP Addresses** section and click **Change**.
2. Add the [IP addresses provided by SimpleBackups](https://simplebackups.com/docs/help-tips-and-troubleshooting/connecting-a-server/simplebackups-ip-addresses-firewall) to the allowlist.

![Aiven IP allowlist configuration screen](https://simplebackups.com/docs/docs-assets/media-helpkit-co/8a484887a0ead62cfea4.png)

You can also configure IP filtering from the **Network** section by choosing **Set public IP filters**.

![Aiven IP filter configuration screen](https://simplebackups.com/docs/docs-assets/media-helpkit-co/8007d975b7e897ad7eb5.png)

![Aiven IP filter entry form](https://simplebackups.com/docs/docs-assets/media-helpkit-co/c3447a2ca9ad79004861.png)

### Step 3: Create a database backup in SimpleBackups

1. Navigate to **Backups** and click **Create Backup**, then select **Database Backup**.
2. Choose **Serverless** as the backup server type.
3. Select the database **Type**: choose **MySQL** for an Aiven MySQL database, or **PostgreSQL** for an Aiven PostgreSQL database.
4. Click **Paste connection string** and paste the connection string you copied, making sure the password is included.
5. Click **Validate Connection**.

For MySQL:

![SimpleBackups database connection form with MySQL connection string](https://simplebackups.com/docs/docs-assets/media-helpkit-co/66ec213f0b841de8ca96.png)

For PostgreSQL:

![SimpleBackups database connection form with PostgreSQL connection string](https://simplebackups.com/docs/docs-assets/media-helpkit-co/1c0672b5fea8f04c39e8.png)

6. Set a schedule for your backups and configure retention policies and storage.

![SimpleBackups backup schedule configuration screen](https://simplebackups.com/docs/docs-assets/media-helpkit-co/6b4251794054bc28fb53.png)

7. Review your configuration and save. SimpleBackups will start backing up your database according to your schedule.

## Restoring a backup

To restore a backup, navigate to your backup page and open the **Logs** tab. Click the detail icon on the backup you want to restore from, then open the **Restore** tab. Generate a download link and copy it.

![Aiven backup logs tab](https://simplebackups.com/docs/docs-assets/media-helpkit-co/91c0917e3f3838cd4bdb.png)

![Aiven backup detail view](https://simplebackups.com/docs/docs-assets/media-helpkit-co/f83eea362d2034b5d315.png)

![Aiven restore tab with download link](https://simplebackups.com/docs/docs-assets/media-helpkit-co/4de5d3179642b92b6309.png)

Run the following command to download and decompress your backup (replace the URL with your signed download link):

```bash
wget -O - "<signed-download-url>" | gunzip -c > backup.pgsql
```

Then restore using `pg_restore`, replacing `<your-database-uri>` with your full database connection string:

```bash
pg_restore -d "<your-database-uri>" ./backup.pgsql
```

**Tip:**
Use the latest version of `pg_restore` to avoid compatibility issues during restore.
