Missing Collections in Local Mongo DB in Meteor App - mongodb

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/

Related

Export number of Documents from mongodb

I use mongochef as a UI client for my mongo database. Now I have collection which consists of 12,000 records. I want to export them using the mongochef.
I have tried with the export option(available) which is working fine up to 3000 documents. But if the number of records gets increasing the system is getting hung up.
Can you please let me know the best way to export all the documents in a nice way using mongochef.
Thanks.
Finally I came to conclusion to use the mongo using terminal which the best way to use(efficient).
read about the primary and secondary databases and executed the following query:
mongoexport --username user --password pass --host host --db database --collection coll --out file_name.json

Where mongoimport store the document in a Docker container

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()

Archive replica set in mongodb

Friends,
I'm a MongoDB DBA and I'm totally new to Mongo and also to DBA role.
I want to archive data that is one month old in a 3 node replica set. mongodump is one option I can achieve this but my client asks me if there are any options. So please could you suggest the available options for archiving the data in replica set.
Many thanks!!!
Yes, we have multiple options.
We can able to take from tools like,
OPS Manager
Atlas
Scripting via
Other than that, if you are trying in manually use MongoDUMP
mongodump --archive=test.20150715.gz --gzip --db test
or
mongodump --gzip --db test
EXTRA
if you want to restore same archive file,
mongorestore --archive --port 27017 --host abc.mongo.com
Refer:
https://docs.mongodb.com/manual/reference/program/mongodump/
https://docs.mongodb.com/manual/reference/program/mongorestore/

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

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.