How to "mongorestore" a Database Dump to a Different Database?

Find out how to use mongorestore to restore to a different DB

If you created a dump of your MongoDB database using the mongodump utility, then you can simply restore it into another database using the mongorestore utility, for example, in the following way:

mongorestore
    --gzip
    --archive=dump_to_restore_from.zip
    --nsFrom "from_db_name.*"
    --nsTo "to_db_name.*"

This would restore all collections in the "from_db_name" database to the "to_db_name" database.

Note the asterisks (*) at the end of the database to/from names. They serve as a wild card for matching all collection names in the database. As a result, all database collections are restored from the "from_db_name" database to the "to_db_name" database.


Hope you found this post useful. It was published . Please show your love and support by sharing this post.