mongodump error – assertionCode: 10057, errmsg: “db assertion failure”


Short Answer

Mongo DB (as of v2.2.2) mongodump cannot be run by a read-only user.


On running mongodump with the usual basic options:

  mongodump --host localhost -u backup -p PASSWORD -o /tmp

the dump failed with this error message being produced:

foobar.system.users to /tmp/foobar/system.users.bson
assertion: 11010 count fails:{ assertion: "unauthorized
 db:foobar ns:popcorn.system.users lock type:1 client:",
 assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }


The error message indicates that the backup user doesn’t have access to the required database, despite having been created on the admin:

$ mongo localhost/admin -u admin -p
MongoDB shell version: 2.2.2
Enter password: 
connecting to: localhost/admin
> db.system.users.find()
{ "_id" : ObjectId("51091aeaffa4fb9aaf9aaca4"), "user" : "admin", "readOnly" : false,
 "pwd" : "2f1bffb1d28a2cca2167910c652b1040" }
{ "_id" : ObjectId("5125ef7b9b9f8d321e38ab91"), "user" : "backup", "readOnly" : true,
 "pwd" : "7154c21931479e96f970ccea160d5469" }

Note that for user backup, its “readOnly” attribute is set to “true”. This will prevent the user from properly accessing the database with the mongodump command, and the backup will fail. It seems a little ill-advised to have to use a user account with full admin permissions just to run backups, but for now, this seems to be the way Mongo DB does things.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>