Is there an existing issue for this?
Current Behavior
With mongodb 4.4 and unifi-network-application 10.1.85, restore of a backup .unf file does not work.
After using the restore button from the web ui, the app restarts, but the backup is not loaded.
Checking the server log, we see that the unifi mongo db user does not have permission for the unifi_restore database.
... <webapi-5> ERROR db - Failed to import config database during backup restore
com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): 'not authorized on unifi_restore to execute command { dropDatabase: 1, $db: "unifi_restore", lsid: { id: UUID("640b77f8-4a75-4460-8089-274bcb0f39cf") } }' on server unifi-db:27017. The full response is {"ok": 0.0, "errmsg": "not authorized on unifi_restore to execute command { dropDatabase: 1, $db: \"unifi_restore\", lsid: { id: UUID(\"640b77f8-4a75-4460-8089-274bcb0f39cf\") } }", "code": 13, "codeName": "Unauthorized"}
I updated my unifi user manually with mongo cli and db.updateUser to give him the role dbOwner for unifi_restore.
After that restore worked as expected.
My suggestion is to update the init-mongo.sh script
#!/bin/bash
if which mongosh > /dev/null 2>&1; then
mongo_init_bin='mongosh'
else
mongo_init_bin='mongo'
fi
"${mongo_init_bin}" <<EOF
use ${MONGO_AUTHSOURCE}
db.auth("${MONGO_INITDB_ROOT_USERNAME}", "${MONGO_INITDB_ROOT_PASSWORD}")
db.createUser({
user: "${MONGO_USER}",
pwd: "${MONGO_PASS}",
roles: [
{ db: "${MONGO_DBNAME}", role: "dbOwner" },
{ db: "${MONGO_DBNAME}_stat", role: "dbOwner" },
{ db: "${MONGO_DBNAME}_audit", role: "dbOwner" },
{ db: "${MONGO_DBNAME}_restore", role: "dbOwner" }
]
})
EOF
Expected Behavior
Restore a backup file should work out of the box.
Steps To Reproduce
Restore a unf file from Settings->System->Backup after a fresh install
Environment
- OS: Debian 13
- How docker service was installed:
distro's packagemanager
CPU architecture
x86-64
Docker creation
Docker compose from the documentation
Container logs
Is there an existing issue for this?
Current Behavior
With mongodb 4.4 and unifi-network-application 10.1.85, restore of a backup .unf file does not work.
After using the restore button from the web ui, the app restarts, but the backup is not loaded.
Checking the server log, we see that the unifi mongo db user does not have permission for the unifi_restore database.
I updated my unifi user manually with mongo cli and db.updateUser to give him the role dbOwner for unifi_restore.
After that restore worked as expected.
My suggestion is to update the init-mongo.sh script
Expected Behavior
Restore a backup file should work out of the box.
Steps To Reproduce
Restore a unf file from Settings->System->Backup after a fresh install
Environment
CPU architecture
x86-64
Docker creation
Container logs