Docs Menu
Docs Home
/ /
MongoDB Command Line Interface
/ / /

mongocli atlas backup restore start

On this page

  • Syntax
  • Arguments
  • Options
  • Output
  • Example

The backup restore start command restores a deployment using the snapshot or point in time of a cluster. You can also restore a deployment using the Atlas UI or API.

mongocli atlas backup restore start <restore-job-type>
--clusterName <cluster-name>
[ --output|-o <output-format> ]
[ --oplogInc <oplog-Inc> ]
[ --oplogTs <oplog-timestamp> ]
[ --pointInTimeUTCMillis <pointInTime-UTC-ms> ]
[ --profile|-P <profile-name> ]
[ --projectId <project-ID> ]
--snapshotId <snapshot-ID>
[ --targetClusterName <cluster-name> ]
[ --targetProjectId <project-ID> ]

Note

Use -h or --help to view the command-line help for this command.

Warning

If you create an automated or pointInTime restore job, Atlas removes all existing data on the target cluster prior to the restore.

Specify the type of restore job with one of the following arguments:

Argument
Description
automated
Atlas restores the snapshot corresponding to snapshotId to the Atlas cluster and project specified by targetClusterId and targetGroupId.
pointInTime
download

Atlas generates and displays a URL to download a .tar.gz of the snapshot corresponding to the snapshotId. The contents of the tar.gz archive contain the data files for your Atlas cluster.

Tip

See also:

To learn more about manually restoring the downloaded data files, see Manual Restore One Snapshot.

Note

Download Limitations

Each cloud backup can have one download at a time, and each project can have a maximum of 20 downloads at a time.

The options required by or available for the command depend on the type of restore job:

Option
Type
Description
Required?
--clusterName
string
Name of the cluster that the job represents.
yes
--profile, -P
string
Name of the profile where the project ID and the Programmatic API Keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.
no
--output, -o
string

Command output format. Valid values are:

  • json for output in JSON format

  • go-template for custom output using the Go template

  • go-template-file for custom output specified using Go template file

If omitted, the command returns output in the default format.

no
--projectId
string

Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable.

no
--snapshotId
string
Unique identifier of the snapshot to use for restore.
yes
--targetClusterId
string
Unique identifier of the target cluster to restore.
yes
--targetProjectId
string
Unique identifier of the project that contains the destination cluster for the restore job
yes
Option
Type
Description
Required?
--clusterName
string
Name of the cluster that the job represents.
yes
--oplogInc
string

Oplog operation number from which to you want to restore this snapshot. This is the second part of an Oplog timestamp.

Three conditions apply to this parameter:

conditional
--oplogTs
string

Timestamp in the number of seconds that have elapsed since the UNIX epoch from which to you want to restore this snapshot. This is the first part of an Oplog timestamp.

Three conditions apply to this parameter:

conditional
--output, -o
string

Command output format. Valid values are:

  • json for output in JSON format

  • go-template for custom output using the Go template

  • go-template-file for custom output specified using Go template file

If omitted, the command returns output in the default format.

no
--pointInTimeUTCMillis
integer

Timestamp in the number of seconds that have elapsed since the UNIX epoch from which you want to restore this snapshot.

Two conditions apply to this parameter:

conditional
--profile, -P
string
Name of the profile where the project ID and the Programmatic API Keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.
no
--projectId
string

Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable.

no
--targetClusterId
string
Unique identifier of the target cluster to restore.
yes
--targetProjectId
string
Unique identifier of the project that contains the destination cluster for the restore job.
yes
Option
Type
Description
Required?
--clusterName
string
Name of the cluster that the job represents.
yes
--output, -o
string

Command output format. Valid values are:

  • json for output in JSON format

  • go-template for custom output using the Go template

  • go-template-file for custom output specified using Go template file

If omitted, the command returns output in the default format.

no
--profile, -P
string
Name of the profile where the project ID and the Programmatic API Keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.
no
--projectId
string

Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable.

no
--snapshotId
string
Unique identifier of the snapshot to use for restore.
yes

The command prints the following fields in the specified format to the terminal if the command succeeds. If the command returns an error, see Troubleshooting for recommended solutions.

Name
Type
Description
cancelled
boolean
Flag indicating whether the restore job was canceled.
createdAt
string
Timestamp in ISO 8601 date and time format in UTC when Atlas created the restore job.
deliveryType
string
Type of restore job to create.
expired
boolean
Flag indicating whether the restore job expired.
expiresAt
integer
Timestamp in ISO 8601 date and time format in UTC when the restore job expires.
finishedAt
integer
Timestamp in ISO 8601 date and time format in UTC when the restore job completed.
id
string
Unique identifier of the restore job.
links
array of objects

One or more links to sub-resources and/or related resources.

snapshotId
string
Unique identifier of the source snapshot ID of the restore job.
target
GroupId
string
Name of the target Atlas project of the restore job.
target
ClusterName
string
Name of the target Atlas cluster to which the restore job restores the snapshot.
timestamp
string
Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.
Name
Type
Description
cancelled
boolean
Flag indicating whether the restore job was canceled.
createdAt
string
Timestamp in ISO 8601 date and time format in UTC when Atlas created the restore job.
deliveryType
string
Type of restore job to create.
expired
boolean
Flag indicating whether the restore job expired.
expiresAt
integer
Timestamp in ISO 8601 date and time format in UTC when the restore job expires.
finishedAt
integer
Timestamp in ISO 8601 date and time format in UTC when the restore job completed.
id
string
Unique identifier of the restore job.
links
array of objects

One or more links to sub-resources and/or related resources.

oplogTs
integer
Timestamp in the number of seconds that have elapsed since the UNIX epoch from which to you want to restore this snapshot. This is the first part of an Oplog timestamp. Returned when "oplogTs" > 0.
oplogInc
integer
Oplog operation number from which to you want to restore this snapshot. This is the second part of an Oplog timestamp. Returned when "oplogTs" > 0.
pointInTime
UTCSeconds
integer
Timestamp in the number of seconds that have elapsed since the UNIX epoch from which Atlas restored this snapshot. Returned when "pointInTimeUTCSeconds" > 0.
target
GroupId
string
Name of the target Atlas project of the restore job.
target
ClusterName
string
Name of the target Atlas cluster to which the restore job restores the snapshot.
timestamp
string
Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.
Name
Type
Description
cancelled
boolean
Flag indicating whether the restore job was canceled.
createdAt
string
Timestamp in ISO 8601 date and time format in UTC when Atlas created the restore job.
deliveryType
string
Type of restore job to create.
deliveryUrl
array of strings

One or more URLs for the compressed snapshot files for manual download. Returned when "deliveryType" : "download".

Note

If empty, Atlas is processing the restore job. Use the /reference/api/cloud-backup/restore/get-all-restore-jobs endpoint periodically check for a deliveryUrl download value for the restore job.

expired
boolean
Flag indicating whether the restore job expired.
expiresAt
integer
Timestamp in ISO 8601 date and time format in UTC when the restore job expires.
finishedAt
integer
Timestamp in ISO 8601 date and time format in UTC when the restore job completed.
id
string
Unique identifier of the restore job.
links
array of objects

One or more links to sub-resources and/or related resources.

snapshotId
string
Unique identifier of the source snapshot ID of the restore job.
timestamp
string
Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.

The following example uses the mongocli atlas backup restore start automated command to restore a deployment. The command uses the default profile where the project ID and the Programmatic API Keys for the source cluster are stored.

mongocli atlas backup restore start automated \
--clusterName myDemo \
--snapshotId 5e7e00128f8ce03996a47179 \
--targetClusterId 5e2f56937a3e5a26326a5ee8 \
--targetProjectId 1a2345b67c8e9a12f3456de7 \
--output json

The previous command prints the following fields to the terminal. To learn more about these fields, see Output.

{
"cancelled": false,
"deliveryType": "automated",
"expired": false,
"expiresAt": "2020-05-04T16:25:01Z",
"id": "5e7e207f6b77fc028bee5e2d",
"links": [
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myCluster/backup/restoreJobs/5e7e207f6b77fc028bee5e2d",
"rel": "self"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myCluster/backup/snapshots/5e7e00128f8ce03996a47179",
"rel": "http://example.mongodb.com/snapshot"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myCluster",
"rel": "http://example.mongodb.com/cluster"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d",
"rel": "http://example.mongodb.com/group"
}
],
"snapshotId": "5e7e00128f8ce03996a47179",
"targetClusterName": "Cluster1",
"targetGroupId": "1a2345b67c8e9a12f3456de7",
"timestamp": "2020-05-03T16:25:01Z"
}

The following example uses the mongocli atlas backup restore start download command to restore a deployment. The command uses the default profile where the project ID and the Programmatic API Keys for the source cluster are stored.

mongocli atlas backup restore start pointInTime \
--clusterName myDemo \
--pointInTimeUTCMillis 1588523147 \
--targetClusterId 5e2f56937a3e5a26326a5ee8 \
--targetProjectId 1a2345b67c8e9a12f3456de7 \
--output json

The previous command prints the following fields to the terminal. To learn more about these fields, see Output.

{
"cancelled": false,
"deliveryType": "download",
"expired": false,
"expiresAt": "2020-05-04T16:25:01Z",
"id": "5e7e207f6b77fc028bee5e2d",
"links": [
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myCluster/backup/restoreJobs/5e7e207f6b77fc028bee5e2d",
"rel": "self"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myCluster/backup/snapshots/5e7e00128f8ce03996a47179",
"rel": "http://example.mongodb.com/snapshot"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myCluster",
"rel": "http://example.mongodb.com/cluster"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d",
"rel": "http://example.mongodb.com/group"
}
],
"pointInTimeUTCSeconds" : 1588523147,
"targetClusterName": "Cluster1",
"targetGroupId": "1a2345b67c8e9a12f3456de7",
"timestamp": "2020-05-03T16:25:01Z"
}

The following example uses the mongocli atlas backup restore start pointInTime command to restore a deployment. The command uses the default profile where the project ID and the Programmatic API Keys for the source cluster are stored.

mongocli atlas backup restore start download \
--clusterName myDemo \
--snapshotId 5e7e00128f8ce03996a47179 \
--output json

The previous command prints the following fields to the terminal. To learn more about these fields, see Output.

{
"cancelled": false,
"deliveryType": "download",
"expired": false,
"expiresAt": "2020-05-04T16:25:01Z",
"id": "5e7e207f6b77fc028bee5e2d",
"links": [
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myDemo/backup/restoreJobs/5e7e207f6b77fc028bee5e2d",
"rel": "self"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myDemo/backup/snapshots/5e7e00128f8ce03996a47179",
"rel": "http://example.mongodb.com/snapshot"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d/clusters/myDemo",
"rel": "http://example.mongodb.com/cluster"
},
{
"href": "https://example.mongodb.com/api/atlas/v1.0/groups/5e3f04ecf10fab66c7d4072d",
"rel": "http://example.mongodb.com/group"
}
],
"snapshotId": "5e7e00128f8ce03996a47179",
"deliveryUrl": "https://example.mongodb.com/backup/restore/v2/pull/5e7e207f6b77fc028bee5e2d/N2UxYTI2MTQwOGI5NGQ3M2FmZWJkMjA5ZjJkYWJjMTE=/myDemo-shard-0-1585315789-5e7e207f6b77fc028bee5e2d.tar.gz",
"timestamp": "2020-05-03T16:25:01Z"
}

Back

Backups