Reputation: 9458
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.
Upvotes: 4
Views: 3332
Reputation: 9665
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.
Upvotes: 5
Reputation: 392
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
Upvotes: 7
Reputation: 3426
mongodb has plenty of tools for export and import of databases. Check out: http://www.mongodb.org/display/DOCS/Import+Export+Tools
Upvotes: 2