I am using mongodump from mongo tools to download a backup of my server. However as I run the command, the command returns "Unrecognized field 'snapshot'".

The full error is:

Failed: error reading collection: Failed to parse: { find: "data", skip: 0, snapshot: true, $readPreference: { mode: "secondaryPreferred" }, $db: "xxx" }. Unrecognized field 'snapshot'.

Mongodump --version returns:

mongodump version: built-without-version-string
git version: built-without-git-spec
Go version: go1.7.3
   os: linux
   arch: amd64
   compiler: gc
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016

I might need to downgrade my version? Otherwise unsure of where to go from here...

  • 1
    What are your versions of O/S and MongoDB server? Your mongodump --version output suggests you have built the tools from source, so it's not obvious what version of MongoDB that might correspond to. Where possible I would suggest downloading the official binaries.
    – Stennie
    Aug 22, 2018 at 0:22

4 Answers 4


Add --forceTableScan


mongodump --forceTableScan -d database_name -o target_directory


The Error comes from the mongo snapshot functionality which was introduced in mongo 4.0 (https://docs.mongodb.com/manual/reference/read-concern-snapshot/)

If you use an older mongo client (<4.0) to dump/export a more recent MongoDB you will get the error

Unrecognized field 'snapshot'

Using "forceTableScan" will prevent the snapshot functionality to become active, this you won't get the error


You certainly have a difference of version between mongodump vs your mongoDB server ( 3.6 vs 4.0).

You can use docker to the rescue :

docker run --rm -v $(pwd):/workdir/ -w /workdir/ mongo:4.0 mongodump -h server -d $database --out /workdir/dump/

With docker you can use a precise version of tools cli without install it.

You can even specify an alias (in .bashrc) :

alias mongodump="docker run --rm -v $(pwd):/workdir/ -w /workdir/ mongo:4.0 mongodump"

Note: The folder where the dump is saved will need to have write permissions so the mongodb user in the container can write to the mounted volume. This can be achieved by manually setting the permissions on the dump folder before running the above command.

In the example above that would be: mkdir -m 777 dump. After the dump is completed then permissions can be modified back to a normal (i.e., sudo chmod 755 dump).

  • 1
    I keep getting the error Failed: error dumping metadata: error creating directory for metadata file dump/{COLLECTION}: mkdir dump: permission denied. I tried with -u 0 and -o /tmp/dump, but couldn't get it to work. I finally ended up starting a container, running the dump, then copying it out of the container. Any ideas where I went wrong with the one-liner?
    – thirdender
    Dec 7, 2018 at 9:59
  • 2
    You need to set the uid appropriately: docker run --rm -v $(pwd):/workdir/ -w /workdir/ -u $(id -u) mongo:4.0 mongodump ...
    – ltn100
    Apr 23, 2019 at 9:55

I was also facing the same issue in CentOS with the below specs where my mongodb authenticated with username and password

enter image description here

I used the below command:

mongodump --forceTableScan -h <mongo database where it is hosted> -u <username>  -d <databasename>  -o /<output directory>/

And entered the mongodb password when prompted.

By default, mongodump uses the _id index when scanning collections with that index is available (e.g. Views do not have any indexes). Specify --forceTableScan to direct mongodump to scan collection data without the use of the _id index.

For more information, just refer this link.


If you dump from Mongo Atlas, this should work.

mongodump --forceTableScan --uri "mongodb+srv://username:[email protected]/db_name"  --out "backup-dir"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.