Navigation
This version of the documentation is archived and no longer supported. It will be removed on 01 March 2021. To learn how to upgrade your version of MongoDB Ops Manager, refer to the upgrade documentation.
You were redirected from a different version of the documentation. Click here to go back.

Automate Backup Restoration through the API

On this page

To restore a snapshot using the API, find the snapshot ID for the snapshot you want to restore, then

Prerequisites

You must have API access. To learn how to get access, see Configure Public API Access.

To find and download the snapshot, your API Key needs read access to snapshots in the desired Project. Grant the API Key the Project Read Only role on the Project that relates to that snapshot.

Procedure

1

Retrieve the snapshot ID.

Call the Get All Snapshots resource to find the ID for the desired snapshot. Issue the following command, replacing:

Name Type Description
PUBLIC-KEY string Your public API Key for your API credentials.
PRIVATE-KEY string Your private API Key for your API credentials.
<OpsManagerHost>:<Port> string URL of your Ops Manager instance.
GROUP-ID string Unique identifier of your Project from your Project Settings.
CLUSTER-ID string Unique identifier of your cluster.
1
2
3
4
5
curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
     --header "Accept: application/json" \
     --header "Content-Type: application/json" \
     --include \
     --request GET "http://<OpsManagerHost>:<Port>/api/public/v1.0/groups/{GROUP-ID}/clusters/{CLUSTER-ID}/snapshots"
2

Create a restore job for the snapshot.

Call the Get One Restore Job resource to request a snapshot restore.

Issue the following command, replacing:

Name Type Description
PUBLIC-KEY string Your public API Key for your API credentials.
PRIVATE-KEY string Your private API Key for your API credentials.
<OpsManagerHost>:<Port> string URL of your Ops Manager instance.
GROUP-ID string Unique identifier of your project that contains the source cluster for the restore job. You can find this value in the Project Settings of that project.
CLUSTER-ID string Unique identifier of your source cluster for the restore job.
TARGET-GROUP-ID string Unique identifier of your project that contains the target cluster for the restore job.
TARGET-CLUSTER-ID string Unique identifier of your target cluster for the restore job.
SNAPSHOT-ID string Unique identifier of the snapshot you want to restore.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
      --header "Accept: application/json" \
      --header "Content-Type: application/json" \
      --include \
      --request  POST "http://<OpsManagerHost>:<Port>/api/public/v1.0/groups/{GROUP-ID}/clusters/{CLUSTER-ID}/restoreJobs"
      --data '
        {
          "delivery" : {
            "methodName" : "AUTOMATED_RESTORE",
            "targetGroupId" : "{TARGET-GROUP-ID}",
            "targetClusterId" : "{TARGET-CLUSTER-ID}"
          },
          "snapshotId": "{SNAPSHOT-ID}"
        }'

Note

To learn more about restoring snapshots with additional examples, see the Create One Restore Job for One Cluster API resource page.