- Back Up MongoDB Deployments >
- Restore MongoDB Instances with Backup >
- Restore a Single Database
Restore a Single Database¶
Overview¶
Backup snapshots contain a complete copy of your mongod
data directory. In MongoDB 2.6 and earlier, you can restore
a portion of your data, such as a single database or collection, from a backup
with the mongodump and mongorestore
tools and the --dbpath
option.
Important
MongoDB 3.0 introduced major changes to the MongoDB tools in order to
support additional storage engines such as WiredTiger.
In MongoDB 3.0, mongodump and mongorestore do not
support the --dbpath
option. As such, you cannot use this
procedure for a partial data restore on a mongod running
MongoDB 3.0.
If you anticipate you will want to restore a single database, create a backup for just that database by excluding the databases or collections that you do not want to back up using the Blacklist field in the Advanced Settings.
Procedure¶
Select and Download a Snapshot¶
Select the Backups tab and then select Replica Set Status.¶
Click the name of the replica set that contains the database to restore.¶
Ops Manager displays your selection’s stored snapshots.
Select the snapshot from which to restore.¶
To select a stored snapshot, click the Restore this snapshot link next to the snapshot.
To select a custom snapshot, click the Restore button at the top of the page. In the resulting page, select a snapshot as the starting point. Then select the Use Custom Point In Time checkbox and enter the point in time in the Date and Time fields. Ops Manager includes all operations up to but not including the point in time. For example, if you select 12:00, the last operation in the restore is 11:59:59 or earlier. Click Next.
Select HTTP as the delivery method for the snapshot.¶
In the Delivery Method field, select Pull via Secure HTTP (HTTPS).
Optionally, you can instead choose SCP as the delivery method. See: Retrieve a Snapshot with SCP Delivery for the SCP delivery option’s configuration. If you choose SCP, you must provide the hostname and port of the server to receive the files and provide access to the server through a username and password or though an SSH key. Follow the instructions on the Ops Manager screen.
Finalize the request.¶
Click Finalize Request and confirm your identify via two-factor verification. Then click Finalize Request again.
Retrieve the snapshot.¶
Ops Manager creates a one-time link to a tar file of the snapshot. The link is available for one download and times out after an hour.
To download the snapshot, select the Ops Manager Backup tab and then select Restore Jobs. When the restore job completes, select the download link next to the snapshot.
If you optionally chose SCP as the delivery method, the files are copied to the server directory you specfied. To verify that the files are complete, see the section on how to validate an SCP restore.
Restore the Database¶
Use the mongodump command to dump a single database.¶
Use the unpacked snapshot restore directory as the dpath
switch
and the single database name as the --db
switch in the
mongodump command:
Use the mongorestore command to import the single database dump.¶
Enter this mongorestore command:
You also may specify the --drop
switch to drop all collections from the target database before you
restore them from the bson
file created with mongodump.