# Restore a Database

You can restore a database cluster in-place from a previous snapshot.

## List available snapshots of a cluster

To restore from a snapshot you will need to provide a snapshot ID. You can request a list of all available snapshots:

### Endpoint

Use the following endpoint to list available snapshots of a clsuter: `https://api.ionos.com/databases/mongodb/clusters/{clusterId}/snapshots`

{% hint style="info" %}
**Note:** The sample cluster UUID is `498ae72f-411f-11eb-9d07-046c59cc737e`.
{% endhint %}

### Request

```bash
curl --include \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
```

### Response

```json
{
  "type": "collection",
  "id": "498ae72f-411f-11eb-9d07-046c59cc737e",
  "items": [
    {
      "type": "snapshot",
      "id": "e2044962-294a-4c99-b076-414b2a387c58",
      "properties": {
        "mongoDBVersion": "7.0",
        "size": 150,
        "creationTime": "2020-12-10T13:37:50+01:00"
      }
    }
  ],
  "offset": 0,
  "limit": 10,
  "_links": {}
}
```

## Restore from backup in-place

You can now create a restore job for the chosen cluster. Your database will not be available during the restore operation. In order to successfully create a restore job, no other active restore job must exist. To restore a cluster in-place you can only use snapshots from that cluster.

{% hint style="info" %}
**Note:** The cluster will have a `BUSY` state and must not receive connections.
{% endhint %}

### Endpoint

Use the following endpoint to list available snapshots of a clsuter: `https://api.ionos.com/databases/mongodb/clusters/{clusterId}/restore`

{% hint style="info" %}
**Note:** The sample cluster UUID is `498ae72f-411f-11eb-9d07-046c59cc737e`.
{% endhint %}

### Request

```bash
curl --include \
    --request POST \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    --data-binary '{
      "snapshotId": "e2044962-294a-4c99-b076-414b2a387c58",
    }' \
```

### Response

The API will respond with a `202 Accepted` status code if the request is successful.

## Point in time recovery

Use the recovery target point in time which specifies the exact oplog timestamp that you choose to restore the database cluster.

### Endpoint

Use the following endpoint for point in time recovery of a cluster: `https://api.ionos.com/databases/mongodb/clusters/{clusterId}/restore`

{% hint style="info" %}
**Note:** The sample cluster UUID is `498ae72f-411f-11eb-9d07-046c59cc737e`.
{% endhint %}

### Request

```bash
curl --include \
    --request POST \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    --data-binary '{
      "recoveryTargetTime": "2023-04-21T13:37:50+01:00",
    }' \
```

### Response

The API will respond with a `202 Accepted` status code if the request is successful.

{% hint style="info" %}
**Note:** Check the cluster details in order to see the progress of the restoration.
{% endhint %}


---

# 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.ionos.com/cloud/databases/mongodb/api/v1-api/restore-a-database.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.
