Fix This Page
Navigation
You were redirected from a different version of the documentation. Click here to go back.

Automate Backup Restoration through the API

Overview

Automating backup restorations involve manipulation of the automation configuration. You first request a restore link through the restoreJobs resource and then add the restore link to the automation configuration using the PUT method.

You must add the restore link to each mongod instance in the automation configuration’s processes array. For example, for a sharded cluster you add the restore link to each member process, including each config server.

To automate backup restoration, you must use PUT. Do not use PATCH.

Prerequisites

You must have access to the Public API. For more information, see Configure Public API Access.

Procedure

1

Retrieve the snapshot ID.

Use the snapshots resource to get the snapshot ID. Issue the following command, replacing <username> and <apiKey> with your API credentials, <url> with the URL of Ops Manager, <group_id> with the group ID from your Group Settings, and <cluster_id> with the cluster ID.

curl -i -u "username:apiKey" --digest "http://<url>/api/public/v1.0/groups/<group_id>/clusters/<cluster_id>/snapshots"
2

Create a restore job for the snapshot.

Use the restoreJobs resource to request an HTTP restore of the snapshot, which will provide a link to a downloadable tar.gz file. Issue the following command, replacing the username, API key, URL, group ID, and cluster ID as in the previous step. Replace <snapshot_id> with the snapshot ID you retrieved.

curl -i -u "username:apiKey" -H "Content-Type: application/json" --digest -X POST "http://<url>/api/public/v1.0/groups/<group_id>/clusters/<cluster_id>/restoreJobs" --data '
{
  "snapshotId": "<snapshot_id>"
}'

For an example, see Create Restore Jobs.

3
4

Retrieve the automation configuration.

Use the automationConfig resource to retrieve the configuration. Issue the following command, replacing <username> and <apiKey> with your API credentials, <url> with the URL of Ops Manager, and <group_id> with the group ID from your Group Settings:

curl -u "<username>:<apiKey>" "http://<url>/api/public/v1.0/groups/<group_id>/automationConfig" --digest -i

Confirm that the version field of the retrieved automation configuration matches the version field in the mms-cluster-config-backup.json file, which is found on any server running the Automation Agent.

5
6

Send the updated automation configuration.

Use the automationConfig resource to send the updated automation configuration.

Issue the following command, replacing <configuration> with path to the updated configuration document. Replace the username, API key, URL, and group ID as in previous steps.

curl -u "<username>:<apiKey>" -H "Content-Type: application/json" "http://<url>/api/public/v1.0/groups/<group_id>/automationConfig" --digest -i -X PUT --data @<configuration>

Upon successful update of the configuration, the API returns the HTTP 200 OK status code to indicate the request has succeeded.

7

Confirm successful update of the automation configuration.

Retrieve the automation configuration from Ops Manager and confirm it contains the changes. To retrieve the configuration, issue the following command, replacing username, API key, URL, and group ID as in previous steps.

curl -u "<username>:<apiKey>" "http://<url>/api/public/v1.0/groups/<group_id>/automationConfig" --digest -i
8

Check the deployment status to ensure goal state is reached.

Use the automationStatus resource to retrieve the deployment status. Issue the following command, replacing username, API key, URL, and group ID as in previous steps.

curl -u "<username>:<apiKey>" "http://<url>/api/public/v1.0/groups/<group_id>/automationStatus" --digest -i

Confirm that the values of all the lastGoalVersionAchieved fields in the processes array match the goalVersion field. For more information on deployment status, see Automation Status.

9

Remove processes.backupRestoreUrl.

When Goal State is achieved, remove the processes.backupRestoreUrl field and resend the automation configuration.