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.
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.