Monday, June 13, 2016

Minimum Mongo Restore Permissions

So this would work to restore a single database: Backup
sudo mongodump -h localhost -d stuffdb --username restoreSingleDB --password Moon1234 \
  -o stuffdb.20160724.dump
Restore
db.addUser( {
    user: "restoreSingleDB",
    pwd: "Moon1234",
    roles: [ "readWrite", "userAdmin" ]
} )

mongorestore --db  --username restoreSingleDB --password Moon1234 /
So this would work to restore all databases including user data:
db.addUser( {
    user: "restoreAll",
    pwd: "Moon1234",
    roles: [ "readWriteAnyDatabase", "userAdminAnyDatabase" ]
} )

mongorestore --username restoreAll --password Moon1234 /

No comments: