Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB Restore Failed

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

like image 733
user2064986 Avatar asked Apr 01 '15 10:04

user2064986


2 Answers

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.

like image 135
Khon Lieu Avatar answered Oct 12 '22 14:10

Khon Lieu


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

like image 2
Sébastien Robert Avatar answered Oct 12 '22 13:10

Sébastien Robert