MongoDB migration - mongodb

Hello I have an ubuntu 14.04 server that is running mongodb 2.4.14. I need to move the mongo instance to a new server. I have installed mongo 3.4.2 on the new server and need to move the databases over. I am pretty new with mongo. I have 2 databases that are pretty big but when I do a mongo dump the file is nowhere near the site of the databases that mongo is showing.I cannot figure out how to get mongoexport to work. What would be the best way to move those databases? If possible can we just export the data from mongo and then import it?

You'll need to give more information on your issue with mongodump and what mongodump parameters you were using.
Since you are doing a migration, you'll want to use mongodump and not mongoexport. mongoexport only outputs a JSON/CSV format of a collection. Because of this, mongoexport cannot retain certain datatypes that exist in BSON and thus MongoDB does not suggest that anyone uses mongoexport for full backups; this consideration is listed on mongo's site.
mongodump will be able to accurately create a backup of your database/collection that mongorestore will be able to restore that dump to your new server.
If you haven't already, check out Back Up and Restore with MongoDB Tools

Related

Can I use mongdb data in my v4.4.5 database that was exported from v3.6.3?

I have a mongodb database with version 3.6.3. I have another mongodb database (on another machine) using version 4.4.5 with no documents in it. I want to put the data from the v3.6.3 into the v4.4.5 database. Can I safetly do this using mongoexport and then mongoimport or do I need to perform more steps?
Yes, mongoexport writes the documents out to a JSON file, and mongoimport can read that file and insert the documents to the new database.
These will transfer only the documents, but not index information. You many want to consider mongodump/mongorestore if you also need to move indexes.

How to avoid auto-updating of MongoDB ObjectIds after restoring the dump using mongorestore command?

I am trying to restore my database dump using mongorestore command. And got to know that some ObjectIds are updating automatically after restoring and am facing data dependency issues with that. Does ObjectIds updates itself while restoring? If yes, is there any alternative to stop that issue?

How to migrate RethinkDb into MongoDb?

My application is using RethinkDb. Everything is running fine, but a new required needs to migrate the db into MongoDb.
Is this possible? How do I migrate the tables/collections, data, indexes, etc?
How about blob types, auto increments. ids?
Thanks!
Is this possible? How do I migrate the tables/collections, data, indexes, etc?
One way to migrate data from RethinkDB to MongoDB is to export data from RethinkDB using rethinkdb dump command, and then use mongoimport to import into MongoDB. For example:
rethinkdb dump -e dbname.tableName
This would generate an archive file:
rethinkdb_dump_<datetime>.tar.gz
After uncompressing the archive file, you can then use mongoimport as below:
mongoimport --jsonArray --db dbName --collection tableName ./rethinkdb_dump_<datetime>/dbName/tableName.json
Unfortunately for the indexes, the format between RethinkDB and MongoDB is quite different. The indexes are stored within the same archived file:
./rethinkdb_dump_<datetime>/dbName/tableName.info
Although you can still write a Python script to read the info file, and use MongoDB Python driver (PyMongo) to create the indexes in MongoDB. See also create_indexes() method for more information.
One of the reasons in suggesting to use Python, is because RethinkDB also has a Client Python driver. So technically, you can also skip the export stage and write a script to connect your RethinkDB to MongoDB.

How to backup Backup mongo db in meteorjs as mongodump is not working

I am new in Meteorjs and i am using mongo db which comes with the meteor package.
I have made one small meteor application using mongodb and now i want to take backup of the mongo db database. I have seen many web sites and still i am not able to backup my data base. Everyone explained the same thing that in mongo db folder use mongodump and mongostore but when i use mongodump and mongostore on my terminal then it displays something like 'mongodump' is not an internal or external source command. Can u please help me in finding out the solution.
I have found that the easiest way to backup your database (or move it between meteor installations for that matter) is to simple copy the files in .meteor\local\db
Then you don't have to worry about all that mongodb dump stuff. Simple.

Copying mongodb

I have a web service application built using NodeJS. I am using mongodb as database.
The whole thing is in another system(A) in the network. Now I need to copy all the data to the mongodb database in my system(B).
Can anyone tell me the whole procedure in detail, like even from where I should execute the commands also. I am a beginner and have very little knowledge about mongodb.
You can use the db.cloneDatabase() command for that (docs).
Start the mongo shell from the command line on the destination server by running: mongo
Identify the name of the database to copy: use name
Copy the database from the source server: db.cloneDatabase("1.2.3.4")
Use mongodump and mongorestore utility.