If you want to export a whole database on MongoDB, this is the tool you are looking for:
mongodump --host <HOST> --port <PORT> --db <DATABASE> --username <USERNAME> --password <PASSWORD>
that will export all your collections into a separate folder. Each collection is exported to a single bson file. After you executed the command you will have a “dump” folder. Under the dump folder there is folder the the name of the DATABASE and under the database folder are the collections on separate bson files.
If you want to import the files into another MongoDB on another server, this is the tool you are looking for:
mongorestore --host <HOST> --port <PORT> --username <USERNAME> --port <PORT> dump/<DATABASENAME>
That worked for me fine 🙂
One thought on “MongoDB Import / Export”
With the –db option it is possible to describe the database to restore into.