I have 500,000 documents inside a collection on a staging server, I need to move these documents to the production server.
What is the best way to move this data, can I let mongodb replicate it from staging to production, do I move the data files or do I do an export and re-import?
So, to export data from the MongoDB database, MongoDB provides a command-line tool known as mongoexport. Using this tool you can exports data of a collection in JSON or CSV(comma-separated value) format. Moreover, we can also use features like limit and sort on a collection while exporting the data.
Use a 64-bit System to Run MongoDB If you have to keep using a 32-bit system, your coding must be very simple to reduce the number of bugs and latency for throughput operations. However for code complexities such as aggregation pipeline and geodata, it is advisable to use the 64-bit system.
MongoDB Relationships are the representation of how the multiple documents are logically connected to each other in MongoDB. The Embedded and Referenced methods are two ways to create such relationships.
To dump a collection do
mongodump -d dbname -c collectionname
On a Windows machine this will create a dump folder under the Mongo 'data' folder with bson files
To restore on a remote host
mongorestore -h hostname -d dbname -c collectionname dump\dbname\collectionname.bson
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With