How to restore the dump into your running mongodb

mongodump:
To dump all the records:

mongodump --db databasename

To limit the amount of data included in the database dump, you can specify –db and –collection as options to mongodump. For example:

mongodump --collection myCollection --db test

This operation creates a dump of the collection named myCollection from the database ‘test’ in a dump/ subdirectory of the current working directory.
NOTE: mongodump overwrites output files if they exist in the backup data folder.


mongorestore:
To restore all data to the original database:

1) mongorestore --verbose \path\dump

or restore to a new database:

2) mongorestore --db databasename --verbose \path\dump\<dumpfolder>

Note: Both requires mongod instances.

Leave a Comment