Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6815

Re: Issues restoring moodle course from 3.11.14 to 3.11.7

$
0
0
by Matthew Willis.  

We got debugging to file workong on this server (was never set up). When reaching the "error writing to database" in the restore process, the logs suggest Moodle is trying to add mdl_user records with mnethostid = 0 but failing because mdl_user already has accounts with the same username. I've attached the full error as an attachment. I'll bring your attention to the following:

> Error writing to database Debug: Duplicate entry '0-redacted.username8' for key 'mdl_user_mneuse_uix'
 
The `0` being the mnethostid value Moodle has calculated for this user and `redacted.username8` being the username imported from the users.xml file in the backup. Not sure how moodle calculates the mnethostid to use. We already have a mdl_user record for the same username, and should be merging the backup record into this user. However, the only way we can get a backup to restore is to perform the following:
  1. Execute the restore
  2. Process the restore
  3. Get to this error writing to database error
  4. Access the database, give the old user id record a unique email and username ('were adding 'duplicate' to both so we can find them easier in a later query if needed)
  5. Repeat these steps until step 3 doesn't occur (i.e. backup restores successfully.

The downside to this is that there are now duplicate user ids for the same human. E.g for this redacted user in my attachment, they would have 2 logins: 1 for their already-enrolled courses, and a second for the content of this backup. Obviously, this is not a tenable solution, as we want a single account per user, especially as we are using LDAP as our primary auth method. 

Is there anything we can do to enforce moodle to set the mnethostid to 1? `select id, username, email from mdl_user where mnethostid <> 1` only returns the users from this backup. `select count(1) from mdl_user where mnethostid == 1` returns all other users on the platform (i.e. those that we create their accounts via the LDAP first-time login process). 

 

Viewing all articles
Browse latest Browse all 6815

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>