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/
Related
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/
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
My mongodb can't lanuch now, when I want start mongo got error ***aborting after invariant() failure
Now I want to restore collection-0-****.wt file to a new db, is this possible?
As at MongoDB 3.2, only full backups of WiredTiger data directories can be copied into a new instance. WiredTiger collection or index files aren't self-contained; they rely on other metadata in the WiredTiger.* catalog files. The invariant/assertion you are getting on startup is expected if data files are incomplete or inconsistent.
If you want to backup and restore a single collection, you should use mongodump and mongorestore, eg:
mongodump --db test --collection northwind --host host1
mongorestore --db test dump/test/northwind.bson --host host2
For supported full backup procedures, see: MongoDB Backup Methods.
I had the same issue and after spending 5 hours doing everything, found this.
https://medium.com/#imunscarred/repairing-mongodb-when-wiredtiger-wt-file-is-corrupted-9405978751b5
You will need to restore 1 collection at a time(a few at once when you get the hang of it), but it works!
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
I have a strange problem with my MongoDB Replica Set backup. I have 2 servers (one primary and one secondary) and I run a backup task every 2 hours.
I use this: mongodump.exe --db MyBase --out "d:\Backups"
But, when I run this backup, my client application (c#) throw errors like this :
MongoDB.Driver.MongoConnectionException: Unable to connect to a member of the replica set matching the read preference Primary
I thought that the mongodump does not have any impact like this on client applications. So, that to say.
I'd like to force my backup operation on the secondary server only. How can I proceed? What is the command to run?
Thank you for your help.
we can also set readPreference in the mongodump command. This feature is available starting mongoDB version 3.2
--readPreference 'secondary'
https://docs.mongodb.com/manual/reference/read-preference/#replica-set-read-preference-modes
If you want to backup secondary, you should write your 'mongodump' command on server, where secondary 'mongod' is running.
Or you can explicitly set secondary host and port:
mongodump.exe --host <secondary_host> --port <secondary_port> --db <db_name> --out <out_folder> --oplog