---
title: "Restore Database"
method: POST
path: "/api/v1/databases/{database_id}/restore"
tags: ["databases"]
---

# Restore Database

`POST /api/v1/databases/{database_id}/restore`

## Request

- Base URL: `https://api.mengi.cloud` (the document declares no server; this is the origin it was published from)
- URL: `https://api.mengi.cloud/api/v1/databases/{database_id}/restore`
- Auth: none declared

Overwrite the database's current data with one of its backups, in place.

`backup_id` is a backup from GET /databases/{id}/backups that has
completed. The database keeps its name, host, user and password, so
connected applications only need to reconnect. Works for PostgreSQL and
MySQL databases that are not part of a replication group.

The restore runs in the background and the database shows the status
`restoring` meanwhile; it is unavailable for most of that time. It
first takes a safety backup of the current data (type `pre_restore`);
if that backup fails, nothing is overwritten and the database returns to
`running` with the reason in `error_message`. On success the database
returns to `running`; if the restore fails after the data was touched,
it goes to `error`.

Responds 202 with the database (status `restoring`), 400 when the backup
cannot be restored in place, 404 when the database or backup is not
found, and 409 when the database is not running or already restoring.

## Path parameters

- `database_id` string, uuid, required

## Request body

- RestoreRequest
  - `backup_id` string, uuid, required

## Response `202`

Successful Response

- DatabaseResponse
  - `id` string, uuid, required
  - `user_id` string, uuid, required
  - `organization_id` string, uuid, nullable
  - `cluster_id` string, uuid, required
  - `name` string, required
  - `engine` 'postgresql' | 'mysql', required
  - `engine_version` string, required
  - `tier` 'single' | 'ha' | 'replicated', required
  - `status` 'pending' | 'provisioning' | 'running' | 'degraded' | 'upgrading' | 'error' | 'deleting' | 'restoring', required
  - `cpu_request` number, nullable
  - `memory_request_mb` integer, nullable
  - `storage_size_gb` integer, required
  - `replicas` integer, required
  - `database_name` string, required
  - `max_connections` integer, nullable
  - `extensions` string[], nullable
  - `external_access` boolean
  - `external_host` string, nullable
  - `connection_host` string, nullable
  - `connection_port` integer, nullable
  - `connection_secret_name` string, nullable
  - `backup_enabled` boolean, required
  - `backup_schedule` string, nullable
  - `backup_retention_days` integer, nullable
  - `git_path` string, nullable
  - `argocd_app_name` string, nullable
  - `replication_group_id` string, uuid, nullable
  - `replication_role` string, nullable
  - `replication_source_id` string, uuid, nullable
  - `replication_host` string, nullable
  - `replication_lag_bytes` integer, nullable
  - `replication_status` string, nullable
  - `error_message` string, nullable
  - `fee_exempt_until` string, date-time, nullable
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/mengi/apis/mengi-cloud.md) · [All operations](https://skmtc.dev/mengi/apis/mengi-cloud/llms.txt) · [OpenAPI document](https://skmtc.dev/mengi/apis/mengi-cloud/revisions/4ae9b375cdbb?raw)
