Restore Archived Data

Serverless Instances are in Preview

Serverless instances are in preview and do not support this feature at this time. To learn more, see Serverless Instance Limitations.

You can restore archived data archived to your Atlas cluster. You must use the $match and $out pipeline stages to get the archived data into a temporary collection and use the $merge to move the data back into the original collection.

This page describes how to restore using $match, $out, and $merge pipeline stages.


See Pause and Resume Archiving for more information.


See Connect to Online Archive for more information.


Use $match to identify the documents that match the criteria for restoring and use $out to Atlas to write the documents to a temporary collection on the Atlas cluster. For example:

{ $match: { $expr: { <aggregation expression> } } },
{ $out: {
"atlas": {
"projectId": "<atlas-project-ID>",
"clusterName": "<atlas-cluster-name>",
"db": "<atlas-database-name>",
"coll": "<atlas-collection-name"
} }
  1. Close the connection you opened in step 2 to your Atlas cluster and online archive.
  2. Connect to your Atlas cluster using the connection string.
  3. Use $merge to move the data from the temporary collection to the original collection. For example:

    $merge: {
    into: "<collection>",
    on: <identifier field>,
    whenMatched: "<replace|merge>",
    whenNotMatched: "<insert|discard|fail>"

See Delete an Online Archive for more information.

Give Feedback