Skip to content

Restore Database

POST
/databases/{database_id}/restore
curl --request POST \
--url https://api.mengi.cloud/databases/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/restore \
--header 'Content-Type: application/json' \
--data '{ "backup_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'

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 returns to exactly the state that backup captured. A target time cannot be given: point-in-time restore is not available. 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.

database_id
required
Database Id
string format: uuid
Media typeapplication/json
RestoreRequest
object
backup_id
required
Backup Id

A completed backup from GET /databases/{database_id}/backups. The database returns to exactly the state this backup captured; restoring to a point in time isn’t supported.

string format: uuid

Example generated

{
"backup_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
}

Successful Response

Media typeapplication/json
DatabaseResponse
object
id
required
Id
string format: uuid
user_id
required
User Id
string format: uuid
organization_id
Organization Id
Any of:
string format: uuid
cluster_id
required
Cluster Id
string format: uuid
name
required
Name
string
engine
required
DatabaseEngine
string
Allowed values: postgresql mysql
engine_version
required
Engine Version
string
tier
required
DatabaseTier
string
Allowed values: single ha replicated
status
required
DatabaseStatus
string
Allowed values: pending provisioning running degraded upgrading error deleting restoring
cpu_request
Cpu Request
Any of:
number
memory_request_mb
Memory Request Mb
Any of:
integer
storage_size_gb
required
Storage Size Gb
integer
replicas
required
Replicas
integer
database_name
required
Database Name
string
max_connections
Max Connections
Any of:
integer
extensions
Extensions
Any of:
Array<string>
external_access
External Access
boolean
external_host
External Host
Any of:
string
connection_host
Connection Host
Any of:
string
connection_port
Connection Port
Any of:
integer
connection_secret_name
Connection Secret Name
Any of:
string
backup_enabled
required
Backup Enabled
boolean
backup_schedule
Backup Schedule
Any of:
string
backup_retention_days
Backup Retention Days
Any of:
integer
git_path
Git Path
Any of:
string
argocd_app_name
Argocd App Name
Any of:
string
replication_group_id
Replication Group Id
Any of:
string format: uuid
replication_role
Replication Role
Any of:
string
replication_source_id
Replication Source Id
Any of:
string format: uuid
replication_host
Replication Host
Any of:
string
replication_lag_bytes
Replication Lag Bytes
Any of:
integer
replication_status
Replication Status
Any of:
string
error_message
Error Message
Any of:
string
fee_exempt_until
Fee Exempt Until
Any of:
string format: date-time
created_at
required
Created At
string format: date-time
updated_at
required
Updated At
string format: date-time

Example

{
"engine": "postgresql",
"tier": "single",
"status": "pending",
"external_access": false
}

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object

Example generated

{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}