mongodb dump fails with cannot unmarshal DNS message
This is just a case of incompatible DNS server. Locate /etc/resolv.conf file and replace the nameserver with 8.8.8.8, and everything should work just fine. If that does not work , try 1.1.1.1.
This is just a case of incompatible DNS server. Locate /etc/resolv.conf file and replace the nameserver with 8.8.8.8, and everything should work just fine. If that does not work , try 1.1.1.1.
Dump command: mongodump –host localhost:27017 –gzip –db Alex –out ./testSO Restore Command: mongorestore –host localhost:27017 –gzip –db Alex ./testSO/Alex Works perfectly! While using archive: Dump command: mongodump –host localhost:27017 –archive=dump.gz –gzip –db Alex Restore Command: mongorestore –host localhost:27017 –gzip –archive=dump.gz –db Alex Note:- While using archive you need to stick with the database name. Different … Read more
Now available from version 3.0.0 –excludeCollection <collection_name> –excludeCollectionsWithPrefix <collection_prefix> Repeat to exclude more than 1 Checkout the documentation
You need to use mongorestore, not mongoimport … which is used for things like importing json, or csv, etc. From the back-up-with-mongodump docs: mongodump reads data from a MongoDB database and creates high fidelity BSON files which the mongorestore tool can use to populate a MongoDB database. mongodump and mongorestore are simple and efficient tools … Read more
work with this: –authenticationDatabase admin mongodump and mongorestore commands need the name of database where mongodb user’s credentials are stored. (thanks @Zubair Alam)
I think it’s just: mongodump –db=<old_db_name> –collection=<collection_name> –out=data/ mongorestore –db=<new_db_name> –collection=<collection_name> data/<db_name>/<collection_name>.bson Also see docs here and here. Btw, the other way to move the collection from one database to another is to use renameCollection: db.runCommand({renameCollection:”<old_db_name>.<collection_name>”,to:”<new_db_name>.<collection_name>”}) Here’s some related SO threads: How to copy a collection from one database to another in MongoDB How to … Read more
On my distro “locale-gen” was not installed and it turned out all I had to do is set the LC_ALL environment variable. so the following command fixed it: export LC_ALL=”en_US.UTF-8″ hopefully it will help someone else…