I am building a web application in Python for which I need MongoDB. I have MongoDB installed on a Mac OS X. And for my app I want to have a Linux VPS. I wanted to know whether I could migrate MongoDB collections from Mac to Linux. Does endianess of the system causes problems? What else might? I am no expert in databases or operating systems. And if we can migrate, can someone point me towards a guide or procedure? Thanks in advance.
You can just run mongoexport, which will dump your database to a file in either JSON or CSV format.
Then, on your new machine, you can run mongoimport with the input file you got from mongoexport, and everything should be there.
mongoexport: http://www.mongodb.org/display/DOCS/mongoexport
mongoimport: http://www.mongodb.org/display/DOCS/Import+Export+Tools?focusedCommentId=4554852#ImportExportTools-mongoimport
While export and re-importing certainly works, this will recreate all the indices from scratch in the new location. For complex indices this could take days.
I wouldn't be surprised in the binary files are compatible - so I would first try shutting down the original server, copying over the entire data directory to the new location. Make sure you are running the exact same version of the mongo server software (e.g. 2.0.x, both 64-bit and both official binaries from 10gen, and with the same configuration options).
I'm pretty sure this will start correctly and all data AND indices will be ready to go. This is basically just taking a binary snapshot of your data files.
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