Questions tagged [mongodump]

Mongodump is a utility for creating a binary export of the contents of a database.

Consider using this utility as part of an effective backup strategy. Use mongodump in conjunction with mongorestore to restore databases.

362 questions
0
votes
1 answer

mongodump to another host

I have the following script: mongodump --gzip -d foobar \ --excludeCollection=foo1 \ --excludeCollection=foo2 \ --excludeCollection=foo3 \ --excludeCollection=foo4 -o ./ But the dump is too large for the server it's on, it's literally taking up…
user5275692
  • 603
  • 1
  • 6
  • 11
0
votes
0 answers

MongoDB - Mongodump utility takes forever to run

I am trying out MongoDB. I have a very small db, like 4 documents in a collection, and that's it. I use MongoDB 3.2.7 on Windows 10. I tried using the mongodump utility to backup the db. It just takes for ever, with no sign of it getting anywhere…
Ren
  • 437
  • 4
  • 17
0
votes
1 answer

MongoDB. Newly added replicaset members can't show databases

I have a Replicaset running with 1 primary and 4 secondaries. The newly added two secondaries give me an error on the show databases command. replicaset:SECONDARY> use admin switched to db admin replicaset:SECONDARY> show databases listDatabases…
0
votes
1 answer

ISODate in --queryFile

I use the below mongodump code to dump records based on a date, in an .sh file: $MONGODUMP_PATH -h $MONGO_HOST:$MONGO_PORT -d $MONGO_DATABASE -c $MONGO_COLLECTION --queryFile subset.json subset.json: { "TheDate": { "$gte": new Date(new…
user1665355
  • 3,324
  • 8
  • 44
  • 84
0
votes
1 answer

using mongodump's query parameter with a Date

Using mongodump with it's query parameter fails when using a query with the Date constructor. Does anyone know why this is? E.g. mongodump --db myDB --collection myCollection --query '{dateCreated:{$gte:new Date("2016/5/18"),$lt:new…
deepseadiving
  • 763
  • 5
  • 18
0
votes
1 answer

Error when running mongodump

I have a rollback file, but when I run mongodump on it I get an error: mongodump.exe .\test.foo.2016-04-27T16-49-54.0.bson > f.json 02:33.521+0100 positional arguments not allowed: [.\test.foo.2016-04-27T16-49-54.0.bson] 02:33.522+0100 try…
BanksySan
  • 27,362
  • 33
  • 117
  • 216
0
votes
1 answer

mongodump lower version mongodb

I tried to use mongodump(Version 3.2.5) to backup MongoDB(version 2.4.9). It sucessed. But I can't restore this backup. Why? ./mongorestore -h 127.0.0.1 -u xxx -p xxx --dir /home/jonkyon/mongo_2 --authenticationDatabase admin…
0
votes
0 answers

how to pass dynamic mongodump --query inside a sh file while calling from java

I have a Java code that code that calls a bash file along with arguments like: String query="'{\"regionID\" : \"2\"}'"; ProcessBuilder pb = new ProcessBuilder("/query/sample.sh", database, collection, query, username, password, host,…
0
votes
1 answer

Pipe MongoDB mongodump to download

On the Linux terminal, I can do a mongodump to stdout using this command: mongodump --db local --collection allnews --out - But how do I get this output, and pipe it to a file that then downloads in the browser..? I have an Apache PHP setup, with…
kingneil
  • 95
  • 2
  • 7
0
votes
1 answer

Unable to backup sharded mongodb cluster: $err: "can't use 'local' database through mongos", code: 13644

I'm unable to backup a sharded mongodb cluster /mongo-metadata/backuptest# mongodump --directoryperdb --oplog --out dump --host 10.100.x.x --port 27017 connected to: 10.100.x.x:27017 assertion: 13106 nextSafe(): { $err: "can't use 'local' database…
JakeJ
  • 13
  • 1
  • 8
0
votes
0 answers

I need to create a bash script to backup 5 collections

The backup needs to happen 3 times a day, and only on collections 1 week old or less. Then it needs to delete anything older than a month. This also needs to run 3 times a day. This is what I have so far but I don't think it will do anything close…
c0d3appl3
  • 163
  • 1
  • 1
  • 5
0
votes
2 answers

Restore mongodump database backup, which is the right flow?

I'm performing my first steps with MongoDB but still lost. I have read the docs here but I'm not able to find the the right steps in order to import|restore the DB. I have a .tgz file and I have uncompressed it. The output of ll command is as…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
0
votes
2 answers

docker-machine ssh command for mongodump

Setup for the problem: Create a data volume container $ docker create --name dbdata -v /dbdata mongo /bin/true Start mongo in a container linked to the data volume container $ docker run -d --name mongo --volumes-from dbdata mongo Verify you can…
Subfuzion
  • 1,789
  • 20
  • 18
0
votes
1 answer

Mongodump query error

mongodump --username user --password password --db db --collection collection --query '{$and: [{"id": "ABCD"}, {"sz": {$gt: NumberLong(100)}}]}' --out dump When executed, mongodump complained with: assertion: 16619 code FailedToParse:…
lolski
  • 16,231
  • 7
  • 34
  • 49
0
votes
2 answers

how to protect the mongo password in shell script?

I have backed up the data from my deployed database successfully using the following commands: mongodump admin -u user -p password Is there a shell script to do this automatically with the password hidden(to protect the password even someone get…
Justlike
  • 1,476
  • 10
  • 18