# Back up and restore Postgres

Create a backup of a Postgres database that you can keep for up to two years, and restore it into a new database. Backups are stored in your team's disaster-recovery bucket and remain available after the source database is deleted.

Backups are separate from the [point-in-time recovery window](/persistence/postgres/reference/recovery-window.md), which only covers the last 2 to 30 days and is deleted together with the database. To restore a database that still exists to a recent point in time, see [Clone or restore Postgres](/persistence/postgres/how-to/restore-point-in-time.md).

Backups are currently managed in Nais Console only. You must be a member of the team.

## Create a backup

1. Open your team in [Nais Console :octicons-link-external-16:](https://console.nais.io) and select **Postgres**.
2. Select the database in the correct environment, then the **Backups** tab.
3. Select **Create backup**.
4. Optionally, change **Backup name**. The default is `<POSTGRES-NAME>-<YYYYMMDD>-<HHMM>` in UTC.
5. Optionally, change **Retention (days)**: 1 to 730, counted from when the backup completes. The default is 30.
6. Select **Create backup**.

The backup runs asynchronously. Its status changes from **preparing** to **running** to **completed**. The list updates automatically while backups are in progress. Once the backup is completed, **Expires** shows when it will be deleted.

If the status is **failed**, hover it to see the reason, and create a new backup when the problem is fixed.

## Restore a backup

A restore creates a new database from a completed backup. It does not overwrite existing databases or move your workloads.

1. Open your team in [Nais Console :octicons-link-external-16:](https://console.nais.io) and select **Postgres**.
2. Find the backup, either in the **Backups** list on the team's Postgres page or on the **Backups** tab of the source database. Backups of deleted databases are only listed on the team's Postgres page.
3. Select **Restore** on the backup. This opens **Create Postgres** with the **Restore from backup** tab and the backup selected.
4. Enter a **Database name** for the new database.
5. Optionally, adjust the resources. See [what the restored database gets](/persistence/postgres/reference/backups.md#restored-database).
6. Select **Restore database**.

The new database's page shows the progress. Wait until it shows **Restore completed** and the database is ready.

Only completed backups that have not expired can be restored, and only into the same team and environment.

To move workloads to the restored database, follow [Move workloads to the clone](/persistence/postgres/how-to/restore-point-in-time.md#move-workloads-to-the-clone) with the new database's name.

## Delete a backup

Backups are deleted automatically when they expire. To delete one earlier:

1. Find the backup in a **Backups** list as described above.
2. Select the trash icon, then **Delete backup**.

Deletion permanently removes the backup from the disaster-recovery bucket and continues asynchronously. A backup cannot be deleted while a restore from it is still in progress.
