0

I want to export an entire mongodb from A mongo to B mongo that are completely equals in terms of structure. They have the same collections and the collections also are equals to. The mongo instances are on different servers something like staging and dev environments. The idea is to do it in just one command like:

mongoexport --host="mongodb0.example.com:27017" --db=reporting <to-other-mongo-host>

Is there an way to do it in "one shot" or I have to do a mongoexport and then a mongoimport?

  • Does this answer your question? [How to copy a collection from one database to another in MongoDB](https://stackoverflow.com/questions/11554762/how-to-copy-a-collection-from-one-database-to-another-in-mongodb) – Wyck Jul 14 '21 at 13:40

1 Answers1

0

For export

mongodump -d <database_name> -o <directory_backup>

For restore

mongorestore -d <database_name> <directory_backup>

Not recommend for big data storages. It is very slow and once you get past 10/20GB of data it can take hours to restore.

Nabil Akhlaque
  • 192
  • 1
  • 8