Where mongoimport store the document in a Docker container - mongodb

So I'm searching where the files are stored after this command
mongoimport --db meteor --collection articles --type csv --headerline --file /data/seeds/articles.csv
I'm using a Docker container from the image mongo:latest
I thought it would be in the /data/db but there isn't my db 'meteor' or my collection 'articles' so I think I'm not in the right folder...
(The application is working perfectly, the data are displayed on the website)
Someone can help me ?

MongoImport imported the csv data into db collection articles.
You will now have to connect to mongod server through mongo shell and run the below commands.
Switch to the db meteor
Use meteor
View collection article
db.article.find()

Related

Missing Collections in Local Mongo DB in Meteor App

My Meteor App local mongoDB is missing 2 collections when compared to my live DB on MLab
Already double checked my connection string and am connected to same DB.
This issue just recently started after pulled a new remote branch but nothing was changed related to the DB.
I don't know what else to try.
What other information can I provide to get a good answer here?
Meteor (or its implementation for MongoDB collections, for that matter) does not actually create the collection until there is a reason for it.
Your collection will not be created in the database until:
a document is inserted into it, or
an index is created for it.
I do not know what was causing the issue but here's what I did to resolve it.
Dump my live database to a local copy:
mongodump --host ds15XXXX-a0.mlab.com --db --port 5XXXXX --username --password
Import to local DB:
mongorestore --drop --host localhost --port 3001 --db meteor ./dump/

Exporting specific gridfs files from MongoDB

I have large number of files in database,I need to take backup of specific week files and export to another database.I can dump fs.files based on uploadDate.
./mongodump --port <port> --db <Database> --collection fs.files --query <json> --out <destination>
How can I export the specific fs.chunks data while iterating fs.files in the shell?
Here's a blog post and the gist for a bash script that will do what's asked for here. Run this script from the command line of the mongodb server. It will loop through the fsfiles collection and exporting the files using the mongofiles utility that is included with MongoDB.
Original Blog Post
Gist

How to dump (backup) several tables (collection) and recover from MongoDB?

I'm new in MongoDB and my english is too bad - so, i can't understand mongodb documentation.
I have to dump (backup) several tables (collection) from MongoDB base - how I can do it?
Which utility I have to use for recover collections from backup?
Thank you for your attention for my question!
Start your mongod server. Assuming that your mongod server is running on localhost and port 27017. Now open a command prompt and go to bin directory of your mongodb instance and type the command:
mongodump
This command will back all data of the server to directory /bin/dump/
To backup only specific collection, use:
mongodump --collection YOUR_COLLECTION_NAME --db YOUR_DB_NAME
On a good-bye note, to restore/recover data use command:
mongorestore

Export and Import Mongodb from Meteor APP

How is it possible to Import and export the MongoDB from Meteor APP into .json or .csv file ?
You can use mongoexport utility to export into a .json or .csv file and mongoimport to import to your db. Detailed info is found here: http://docs.mongodb.org/v2.2/reference/mongoexport/
If you intend to reimport into mongodb, mongodump might be a bit better since you won't be losing type information
Try mongodump
mongodump --host 127.0.0.1:3001
Here you get BSON, and separate key indexes in json files. Then you can use the dumps to restore your db (if this is your intention):
If you're in the dump directory from above:
mongorestore --host 128.199.224.29:27017 --db meteor .

MongoDB storing data in two different locations

I'm sort of new at MongoDB and running into a few problems with locating/accessing data that I've created or imported, in that it's ending up in two distinct locations.
If I start the shell like this
$ mongo
and then show the databases
$ show dbs
this gives me a list of about 10 databases that I've created. These are in the /data/db directory It does not include a db called 'pact'
However, if I connect like this
$ mongo localhost/pact
and then do
$show dbs
it only lists one db, the pact db, which isn't listed when I connect to mongo the other way by just doing 'mongo.' 'Pact' isn't in the /data/db directory. According to my notes, I might have made the 'pact' db by starting mongod this way,
mongod --dbpath data
which I would think would position it in the data/db directory, and I imported into the pact directory like this
mongoimport --stopOnError --db pact --collection products < products.json
Moving on, if I use mongo in irb and start like this
>> mongo_client = MongoClient.new("localhost", 27017)
and then do 'show dbs'
I get the long list of dbs from the /data/db directory (which didn't include pact).
In order to find db pact through irb, I tried to include it after localhost, as I do with mongo localhost/pact
>> mongo_client = MongoClient.new("localhost/pact", 27017)
but I got an error.
1 Is there a way I can find out what directory the 'pact' db is in?
2 How can I access it in irb with the Mongo driver if not by
mongo_client = MongoClient.new("localhost/pact", 27017)
which I assumed would work since I can do this in the shell mongo localhost/pact
3 Based on what I've told you, can you explain why this happened (I'm assuming it's not the proper way to have data saved in another directory)
My suggestion is to use mongodump in mongo localhost/pact shell context
mongodump -d pact -o /out/dir
to backup the entire database. And use mongorestore at normall mongo shell context
mongorestore -d pact /out/dir
to restore the database.