mongodump

Mongodb monogorestore “root directory must be a dump of a single database”

只愿长相守 提交于 2019-12-18 09:02:09
问题 I'm trying to restore a mongodump to a differently named database (which should be possible via --db <dbname> switch). My working directory contains a single dump folder, which contains a single db dump. However, when I try this command: mongorestore --port xxxxx --db some_destination_db I get the following error: ERROR: ERROR: root directory must be a dump of a single database ERROR: when specifying a db name with --db I have no idea why I'm getting this, and can't find any help on google.

How to use the dumped data by mongodump?

我与影子孤独终老i 提交于 2019-12-17 15:34:28
问题 I have used mongodump to dump my database of mongodb, it created some bson files under dump/mydb But I don't know how to use them. I tried mongoimport , but seems it can't import bson data. Then how to use these bson files? How to import them to another mongodb? 回答1: 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

mongodump “Failed: bad option: can only dump a single collection to stdout”

孤者浪人 提交于 2019-12-13 20:19:50
问题 mongodump --out "-" doesn't work, it gives me this message : "Failed: bad option: can only dump a single collection to stdout". What happens ?... 回答1: so the exception is self-explanatory that if you use --out "-" it can show only single collection on stdout. So i would like to know as to what you want to achieve? if you want to stdout a particular collection command is : mongodump -o - -d <dbname> -c <collection name> if you want to take dump of whole mongodatabase ideal command is:

mongodb dump and pipe to other db name

别说谁变了你拦得住时间么 提交于 2019-12-11 05:49:14
问题 Mongodb version 3.2.12. I have two local databases, "base1" and "base2" I want to copy all data (all collections) from base1 over to base2, replacing everything there (like when dumping production to a dev environment). Any pipe command (or other simple way) to do this? I tried mongodump --archive --db base1 | mongorestore --db base2 --archive lists a lot of "writing base1.collectionname to archive on stdout", but nothing gets written to base2. I also tried mongodump --db base1 --gzip -

How to limit CPU and RAM resources for mongodump?

我与影子孤独终老i 提交于 2019-12-11 02:02:06
问题 I have a mongod server running. Each day, I am executing the mongodump in order to have a backup. The problem is that the mongodump will take a lot of resources and it will slow down the server (that by the way already runs some other heavy tasks). My goal is to somehow limit the mongodump which is called in a shell script. Thanks. 回答1: You should use cgroups. Mount points and details are different on distros and a kernels. I.e. Debian 7.0 with stock kernel doesn't mount cgroupfs by default

Mongodb's “mongodump” command, javascript execution error

随声附和 提交于 2019-12-10 03:19:17
问题 Perhaps I have a complete misunderstanding of how mongodump is supposed to work, but I can't seem to get it to do anything besides returning a JavaScript execution failed: SyntaxError: Unexpected identifier error. Here's what I'm doing: Mongod is running I want to backup a database called "mydb" I'm inside the mongo shell I tried the command mongodump --db mydb and get the above error I've tried both mongodump and mongoexport , both have the same issue What am I doing wrong here? 回答1: Try the

Importing mongo collection into existing collection without overriding it

好久不见. 提交于 2019-12-08 08:24:35
问题 Is it possible to import a mongodump into a existing collection adding to it (not overriding it)? If yes, how? Would it be using mongoimport --db mydb ? The collections are the same in structure but simple have different datasets from different instances of the same app. I'd like to merge all data into a single database. 回答1: Use mongorestore. It is overwriting the collection only if you specify --drop parameter. So if you do nothing it will just add new element (thus doing what you want).

MongoDB - Get the size of all the documents in a query

只愿长相守 提交于 2019-12-07 16:29:00
问题 Is there's a way to get the size of all the documents that meets a certain query in the MongoDB shell? I'm creating a tool that will use mongodump (see here) with the query option to dump specific data on an external media device. However, I would like to see if all the documents will fit in the external media device before starting the dump. That's why I would like to get the size of all the documents that meets the query. I am aware of the Object.bsonsize method described here, but it seems

MongoDB - Get the size of all the documents in a query

末鹿安然 提交于 2019-12-06 03:24:41
Is there's a way to get the size of all the documents that meets a certain query in the MongoDB shell? I'm creating a tool that will use mongodump (see here ) with the query option to dump specific data on an external media device. However, I would like to see if all the documents will fit in the external media device before starting the dump. That's why I would like to get the size of all the documents that meets the query. I am aware of the Object.bsonsize method described here , but it seems that it only returns the size of one document. Here's the answer that I've found: var cursor = db

mongodb how to mongodump only indexes to another mongodb instance

杀马特。学长 韩版系。学妹 提交于 2019-12-04 18:50:40
问题 I have a mongodb instance with a lot of data, now I need to start up a new instance with the same structure without data. how to get it done? 回答1: You can do that with the "query" option, with a query that does not return any document. Something like: mongodump -q '{ "foo" : "bar" }' This will dump all the dbs and indexes, you can then do a mongorestore to recreate them into another mongod instance See documentation: http://docs.mongodb.org/manual/reference/program/mongodump/#cmdoption--query