Importing data into MongoDB Atlas - mongodb

I have a local database/collection that I created from an external .bson file using mongorestore. I'm able to access the collection from my local machine, however, it's not updated in MongoDB Atlas.
How exactly can I import it? It seems that mongoimport only works with json files.

Related

MongoDB Atlas Sync to Local disk and archive

I have a MongoDB Atlas cloud database,
and I want to "sync" to a local server instance with mongod server running.
I have written an automated backup script that backs up a website, which then also does a mongodump to create an archive file from the (local) MongoDB, which then all gets dumped to an AWS bucket.
It's been working great, but I just realized that it's getting the local disk's mongo data, and not the "live" data on the Mongo Atlas cloud.
Is there a way mongodump can dump the MongoDB Atlas stuff to the local disk?
I hope there is an easier way than to "find" all on individual Atlas collections in my database, and "update" to the local disk.
I was successfully able to get a dump from Atlas to my local server using mongodump.
mongodump --forceTableScan --url="mongodb+srv://<username>:<password>#yourmongoserver.something.mongodb.net/<database name>"
Note this failed until I included the --forceTableScan, which then after was seemingly successful.

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.

MongoDB migration

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

How to export meteor mongodb data to CSV or any other file format?

I have an application which collects Email, Phone number, Address etc. I want to get this data from meteor mongo db and export it into some kind of a file format (Maybe CSV).
I tried using mongoexport but that even didnt work.
mongoexport
Whats the command to export meteor database data into a file or is there any kind of package.
FYI: application is stored on amazon ec2 instance.
You can still use mongoexport, you just need to point it at the meteor-internal mongodb:
mongoexport --port=3001
Just make sure meteor is running when you issue this command.
This is assuming you are running in development (using meteor, not a bundle), and using the default port (3000).

GridFS issues with a Mongo Import

I have a production server running Mongo 2.0.7 and a local machine that runs Mongo 2.0.6.
I exported a database as a JS file and then imported it in my local machine. EVerything seems to be working fine however I am unable to server GridFS files. That is when I try accessing that resource, I get corrupt data and thus no image. Any thoughts? I tried looking at the change log for the version change and saw nothing that could effect that?
Thanks
I'm guessing that you used mongoexport to produce the JSON dumps. mongoexport does not provide the same data fidelity as mongodump, so try that instead.