Failed to restore MongoDB

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

This is the command that I run and the error that I get.

mongorestore / home / somename / backups / staging / mongo

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

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

2015-04-01T12: 12: 32.896 + 0200 Failure: user and role collections in the dump have an incompatible auth version with the target server: it is not possible to restore users of version 1 for version 1 on a server of version 5 version

Is there any way around this or fix it?

Any help would be greatly appreciated

+7
mongodb mongorestore
source share
3 answers

You can work around this problem by moving the admin directory from the dump folder, and then re-run the mongorestore command.

For example, if you run

 mongorestore --dir ~/path/to/mongodumpdir 

and this failed, then most likely you have an admin folder. You can move it and run the command above again.

I believe this is especially important for the system.users.bson causing the problem. Since mongo 2.xx and 3.xx add and store users in different ways.

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

+11
source share

Try adding the authentication database in the CLI command as: --authenticationDatabase admin

+2
source share

Try adding --authenticationMechanism SCRAM-SHA-1

refer to the docs: https://docs.mongodb.com/manual/reference/program/mongorestore/#cmdoption--authenticationMechanism

0
source share

All Articles