Search code examples
mongodbmongodump

Mongodump 0 document dumped


I've got a problem with mongodump command line inside a docker container.

I'm trying to dump some document of a collection by using query parameter. When I run the command, sometimes I've got my results, sometimes I have nothing... I would like to understand why. Moreoever, how can I solve this problem ??

mongod -v : 3.6.13

Here the command line I run :

mongodump --host 127.0.0.1:27017 -d database -c product -q '{namespace: {x: "5e15ae8bd38f02057213c9e2", y: "5e15af64d38f02056a0b978a", z: "5e15af64d38f02057b672527"}}' -o /backup/       

And the result :

root@e2bdce2fa15a:/backup/database# mongodump --host 127.0.0.1:27017 -d database -c product -q '{namespace: {x: "5e15ae8bd38f02057213c9e2", y: "5e15af64d38f02056a0b978a", z: "5e15af64d38f02057b672527"}}' -o /backup/
2020-03-05T16:02:14.779+0000    writing database.test_value to 
2020-03-05T16:02:14.785+0000    done dumping database.test_value (12 documents)
root@e2bdce2fa15a:/backup/database# mongodump --host 127.0.0.1:27017 -d database -c product -q '{namespace: {x: "5e15ae8bd38f02057213c9e2", y: "5e15af64d38f02056a0b978a", z: "5e15af64d38f02057b672527"}}' -o /backup/
2020-03-05T16:02:15.454+0000    writing database.test_value to 
2020-03-05T16:02:15.464+0000    done dumping database.test_value (0 documents)

Any idea ? Thank you very much !


Solution

  • You need to change your query to this one:

    -q '{"namespace.x": "5e15ae8bd38f02057213c9e2", "namespace.y": "5e15af64d38f02056a0b978a", "namespace.z": "5e15af64d38f02057b672527"}'