This version of the documentation is archived and no longer supported. 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.

Restore a Single Database


Backup snapshots contain a complete copy of your mongod data directory. There may be occasions when you want to restore only part of the data in a snapshot. To restore a single database instead of all databases in the snapshot, load the snapshot first to a temporary mongod instance and then export from this instance the single database. Use the export of the single database to restore to the target deployment.


As of MongoDB 3.0, mongodump and mongorestore no longer support the --dbpath option. These tools now must connect to a running mongod instance.


Before you attempt a restore, ensure your target storage has sufficient space for the restore files and the restored database, plus additional space for dataset growth. Use db.stats() to find the current database size.

Select and Download a Snapshot


Click Backup, then the Overview tab.


Click the deployment’s ellipsis icon and select Restore.


Select the restore point.

Choose the point from which you want to restore your backup.

Restore Type Description Action
Snapshot Allows you to choose one stored snapshot. Select an existing snapshot to restore.
Point In Time

Creates a custom snapshot that includes all operations up to but not including the selected time.


If you select 12:00, the last operation in the restore is 11:59:59 or earlier.

Select a Date and Time.
Oplog Timestamp

Creates a custom snapshot based on the timestamp of an oplog entry (its ts field). Ops Manager includes all operations up to and including the time of the timestamp.

The oplog entry’s ts field is a BSON timestamp and has two components: the timestamp and the increment.

Type the following:

The value in seconds since the Unix epoch.
An incrementing ordinal for operations within a given second.

Click Next.


Choose how to receive the restore files.

Select the restore method, format and destination.

Pull Via Secure HTTP
  1. Type a direct download link.

  2. Select from the following options:

    Pull Restore Usage Limit

    Select whether the link can be re-used or used just once. If you select No Limit, the link is re-usable until it expires.

    Restore Link Expiration (in hours)

    Select the number of hours until the link expires.


You can skip the remainder of this procedure.

Push Via Secure Copy

Direct Ops Manager to copy the restore files to your server via SCP.


SCP requires you to generate a key pair before attempting to transfer files. SCP provides faster file delivery than HTTP.


Microsoft Windows computers do not include SCP and require additional setup outside the scope of this manual.


Select the format in which you want to receive the restore files:

Individual DB Files
Transmits MongoDB data files produced by Ops Manager directly to the target directory.

Delivers database files in a single archive (tar or tar.gz) that you must extract before restoring the databases to a working directory.

This option displays only if the archive size can be calculated.

With Archive delivery, you need sufficient space on the destination server for both the archive and the extracted files.

SCP Host Type the hostname of the server to receive the files.
SCP Port Type the port of the server to receive the files.
SCP User Type the username used to access to the server.
Auth Method Select whether to use a username and password or an SSH certificate to authenticate to the server.
Password Type the user password used to access to the server.
Passphrase Type the SSH passphrase used to access to the server.
Target Directory Type the absolute path to the directory on the server to which to copy the restore files.

If the snapshot is encrypted, the restore panel displays the KMIP master key id and the KMIP server information. You can also find the information when you view the snapshot itself as well as in the restoreInfo.txt file.

Click Finalize Request.


Retrieve the snapshot.

If you selected Pull Via Secure HTTP:

Ops Manager creates a link to the snapshot. By default, this link is available for an hour and can be used just once. To download the snapshot:

  1. Click Backup, then the Restore History tab.
  2. When the restore job completes, select the download link next to the snapshot.
If you selected Push Via Secure Copy:
The files are copied to the server directory you specified. To verify that the files are complete, see how to validate a secure copy restore.

Restore the Database

The following examples use:

  • 27017 as the port for a running MongoDB instance that receives the restored backup.
  • 27018 as the port for the temporary MongoDB instance that uses the snapshot to export the single database.

Restore the snapshot data files to the server.

Extract the snapshot archive to a temporary location where a temporary mongod process will access the archive contents. Use a different data directory than any other database running on the server.

For example:

tar -xvf <backupRestoreName>.tar.gz
mv <backupRestoreName> <temp-database-path>

Start a new, temporary MongoDB process on a new port using the extracted backup snapshot as the dbpath.

Ensure the user executing the mongod can read, write and execute code in the directory specified with dbpath.

For example:

mongod --port 27018 --dbpath <temp-database-path> --logpath <temp-database-path>/mongodb.log --fork

Use the mongodump command to export a single database or collection from the temporary running mongod process.

Specify the single database name using --db and, if needed, a --collection for a single collection.

The --out option specifies where the mongodump extracts the target database. Choose an empty directory the user executing mongodump can access.

mongodump --port 27018 --db <single-database> --out <new-database-path>

It also possible to export only a single collection:

mongodump --port 27018 --db <single-database> --collection <collection-name> --out <new-database-path>

Use the mongorestore command to import the single database or collection.

Restore the single database to the desired instance using this mongorestore command:

mongorestore --port 27017 --db <single-database> <temp-database-path> --drop

If you are restoring a single collection, be sure to designate the collection:

mongorestore --port 27017 --db <single-database> --collection <collection-name> <temp-database-path> --drop

Any existing databases matching the name given for the --db option should be dropped using the --drop option. If you choose not to use the --drop option, the restore may produce errors for any documents with duplicate _id fields.


Shutdown the temporary MongoDB instance and remove the temporary database.

  1. Start the mongo shell.

    mongo <port>
  2. Drop the database and shutdown the process.

    admin = db.getSiblingDB("admin")
  3. Delete the temporary database directory

    rm -rf <temp-database-path>