MongoDB Restore failed for system.users collection

We encountered an error while attempting to restore a backup created with mongodump. The error message suggests an issue with the authentication version. The error message is as follows:

“Failed: the users and roles collections in the dump have an incompatible auth version with the target server: cannot restore users of auth version 1 to a server of auth version 5.”

This issue is occurring when attempting to restore users and roles from a dump created with an authentication version 1 to a server with authentication version 5. This incompatibility is preventing the restoration process. The commands used for backup and restore are as follows:

Backup Command:

mongodump --host 127.0.0.1 --port 27017 --authenticationDatabase="admin" --username admin --password "" --db=admin --collection system.users --archive=/data/dump/users_and_roles.gz

Restore Command:

mongorestore --host 127.0.0.1 --port 27017 --authenticationDatabase=“admin” --username admin --password “” --db=admin --collection system.users --archive=/data/dump/users_and_roles.gz

Please assist me to fix the issue. Thanks in advance !

Is the server being restored to the same version as the source ?

When using mongorestore to load data files created by mongodump, the MongoDB versions of your source and destination deployments must be either:

  • The same major version.
  • The same feature compatibility version.

https://www.mongodb.com/docs/database-tools/mongorestore/#restore-to-matching-server-version

1 Like