> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/database-as-a-service/mongodb/api-howtos/restore-a-database.md).

# 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:

{% hint style="info" %}
Our chosen `clusterId` is: <mark style="color:red;">cc54e0f2-5e49-42bf-97e8-089c2eff0264</mark>
{% endhint %}

#### Request

```bash
curl --include \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    https://api.ionos.com/databases/mongodb/clusters/cc54e0f2-5e49-42bf-97e8-089c2eff0264/snapshots
```

#### Response

```json
{
  "type": "collection",
  "id": "cc54e0f2-5e49-42bf-97e8-089c2eff0264",
  "items": [
    {
      "type": "snapshot",
      "id": "e2044962-294a-4c99-b076-414b2a387c58",
      "properties": {
        "mongoDBVersion": "5.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.

{% hint style="info" %}
**Note:** To restore a cluster in-place you can only use snapshots from that cluster.
{% endhint %}

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

**Restore snapshot 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",
    }' \
    https://api.ionos.com/databases/mongodb/clusters/cc54e0f2-5e49-42bf-97e8-089c2eff0264/restore
```

**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.

**Point in time recovery 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",
    }' \
    https://api.ionos.com/databases/mongodb/clusters/cc54e0f2-5e49-42bf-97e8-089c2eff0264/restore
```

**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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/database-as-a-service/mongodb/api-howtos/restore-a-database.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
