8
votes

I'm trying to restore a mongodb database from a dump in Ubuntu 14.04.2, the dump was created on MongoDB shell version: 2.4.13 and I'm restoring on MongoDB shell version: 3.0.1.

This is the command I'm running and the error I'm getting.

mongorestore /home/somename/backups/staging/mongo

2015-04-01T12:12:32.886+0200 building a list of dbs and collections to restore from /home/somename/backups/staging/mongo dir

2015-04-01T12:12:32.896+0200 assuming users in the dump directory are from <= 2.4 (auth version 1)

2015-04-01T12:12:32.896+0200 Failed: the users and roles collections in the dump have an incompatible auth version with target server: cannot restore users of auth version 1 to a server of auth version 5

Is there a way around it or a fix?

Any help will be much appreciated

3
We are software developers, not database administrators. I nominated your question for migration to dba.stackexchange.comPhilipp

3 Answers

13
votes

You can get around this issue by moving the admin directory out of the dump folder, then re-run the mongorestore command.

For example if you ran

mongorestore --dir ~/path/to/mongodumpdir

and it failed, then most likely you have an admin folder in there. You can move it out, and re-run the command above.

I believe, specially, it's the system.users.bson that's causing the problem. Since mongo 2.x.x and 3.x.x add and store users differently.

Of course, users from your old mongodb won't be available in your new db, but you can always manually add them back in.

2
votes

Try to add authentification database in CLI command as : --authenticationDatabase admin