mongorestore

Restoring the database can be accomplished by issuing the command mongorestore. This command will import a binary export of either a mongod or a mongos instance. The command options you can use are the same as with mongodump, with these additions:

-v Verbose: Gives you more information during the restore
-dryRun Shows you what would happen if you actually performed the restore
--drop Drops the collection before performing the restore

 

You can have a look here for more options regarding commands: https://docs.mongodb.com/manual/reference/program/mongorestore/#mongorestore.

In the following example, we are doing a dry run of restoring the sweetscomplete.customers collection to replicate the set sweets_33:

Instead of ...

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.