Docs Menu

Docs HomeMongoDB Ops Manager

Automate Backup Restoration through the API

On this page

  • Prerequisites
  • Variables for Automated Restore API Resources
  • Procedure

To restore a snapshot using the API:

  1. Find the ID of the snapshot that you want to restore.

  2. Create a restore job using that snapshot ID.

You must have API access. To learn how to get access, see Configure 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.

The API resources use one or more of these variables. Replace these variables with your desired values before calling these API resources.

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

Call the Get All Snapshots resource to find the ID for the desired snapshot.

Invoke the following command:

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--request GET "https://<OpsManagerHost>:<Port>/api/public/v1.0/groups/{PROJECT-ID}/clusters/{CLUSTER-ID}/snapshots?pretty=true"
2

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

Invoke the following command:

1curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
2 --header "Accept: application/json" \
3 --header "Content-Type: application/json" \
4 --request POST "https://<OpsManagerHost>:<Port>/api/public/v1.0/groups/{PROJECT-ID}/clusters/{CLUSTER-ID}/restoreJobs?pretty=true" \
5 --data '
6 {
7 "delivery" : {
8 "methodName" : "AUTOMATED_RESTORE",
9 "targetGroupId" : "{TARGET-PROJECT-ID}",
10 "targetClusterId" : "{TARGET-CLUSTER-ID}"
11 },
12 "snapshotId": "{SNAPSHOT-ID}"
13 }'

Note

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

←  Update the MongoDB Version of a DeploymentUpload the Latest Version Manifest to Ops Manager with the API →