Importing 2.9 DB backup to 3.5 moodle version

Importing 2.9 DB backup to 3.5 moodle version

by Joel Mendoza -
Number of replies: 12

Hi community, I'm having some issues because one of my customers asked me to migrate his existing moodle version (2.9) to a more recent one (3.5). I've migrated sucessfully from their original database and everything was working ok. However the customer continued using his old version in another server and now is time to put their new data in our database. They sent database dump and I imported it.

The problem is now things are not working so good, first I'm not sure if just needed to import the DB dump getting only the inserts and skipping "drop table" statements (I did it), but didn't notice any change in data.

Maybe I'm doing something wrong. Please help.

Average of ratings: -
In reply to Joel Mendoza

Re: Importing 2.9 DB backup to 3.5 moodle version

by Ken Task -
Picture of Particularly helpful Moodlers

Hope you did a DB dump of the 3.5 *before* importing.
Might have to restore that to get things working properly.

That DB dump they sent needed to be a *very special* one which captured just the new data for accounts/courses/anything that were from date of the first migrated db dump up to the date of the making of that dump.

'very special' defined (loosely) ... and a poor explanation/example ...

All the quiz data from **all** quiz related tables from a certain date in past up to present day.

| mdl_quiz                       |
| mdl_quiz_attempts              |
| mdl_quiz_feedback              |
| mdl_quiz_grades                |
| mdl_quiz_overrides             |
| mdl_quiz_overview_regrades     |
| mdl_quiz_reports               |
| mdl_quiz_sections              |
| mdl_quiz_slot_tags             |
| mdl_quiz_slots                 |
| mdl_quiz_statistics            |

ditto for all mods which involved student interaction/submission.  Another poor explanation/example - assignments and files uploaded by
students ...

| mdl_assign                       |
| mdl_assign_grades                |
| mdl_assign_overrides             |
| mdl_assign_plugin_config         |
| mdl_assign_submission            |
| mdl_assign_user_flags            |
| mdl_assign_user_mapping          |
| mdl_assignfeedback_comments      |
| mdl_assignfeedback_editpdf_annot |
| mdl_assignfeedback_editpdf_cmnt  |
| mdl_assignfeedback_editpdf_queue |
| mdl_assignfeedback_editpdf_quick |
| mdl_assignfeedback_file

+ filedir if students uploaded files for assignment - won't try
to provide example.

So what did that last sql dump have in it?

When you go to Notifications of new site is it still reporting
3.5.x version?

How about going into any course that was used and looking at course logs?

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Importing 2.9 DB backup to 3.5 moodle version

by Joel Mendoza -
Thank you very much for your help Ken. Yes, fortunately I have the 3.5 backup (thanks to God!). To be honest I'm trying to figure out if the best approach is to ask for such *very special* backup you suggest or better try to start over the whole installation starting from 2.9, 3.2 and then 3.5. This though is because there is no support from previous vendor, so they provided full backup and suddendly dissapeared, there is no opportunity for a new backup. They also sent filedir to refresh files and so on. In terms of notifications, when I import dump as it is, keeping "drop tables" statements, I got an error saying my installed version of moodle is different than the imported database and can't continue. That's why I decided edit the sql file to commit all drops and only take into account inserts and that triggers the mentionet behavior.

Another trial could be have the full list of tables involved in such students interactions and only get and import such information from the backup. Is the list you provided, the full list of students interactions?

Thanks again.
Joel
In reply to Joel Mendoza

Re: Importing 2.9 DB backup to 3.5 moodle version

by Ken Task -
Picture of Particularly helpful Moodlers

Let's start with this:

"Another trial could be have the full list of tables involved in such students interactions and only get and import such information from the backup. Is the list you provided, the full list of students interactions?"

what I provided was a very poor example but thought it might suffice to describe ... no ... list provided not full ... there are probably near 3-4000+ tables and remember, MySQL/MariaDB is a 'relational' SQL DBM.

Would take the skills of a MySQL/MariaDB guru of guru's me thinks.  So entire DB would be best.

Bad news 2 ...

"error saying my installed version of moodle is different than the imported database and can't continue."

You have 3.6.x code and DB is 2.9.x.  The import of last SQL was for 2.9.x code. sad

fix ... restore your backup taken just prior to importing ... the code you did not touch ... right?  moodledata/filedir you did not touch ... right?

If so, restore of DB only thing needed to get back to square one.

Now moving forward ... if the last sql dump they gave you was for site and version 2.9.x and moodledata but no code, get the 2.9.highest code using new DB dump and moodledata should result in a minor update ... 2.9.x to 2.9.highest.

Then begin the march to 3.5.highest again.  If you were using git repo for code, could probably get'er done in 4 hours or a day ... depending upon size of site.

If not using git ...  painful, yes ... probably cursing all the way, but .... :|

Know you might not want to hear this now (virtual finger wag) ... but next time ... get a cutoff date/time in writing.   The site in maintenance mode on that date/time and doesn't come out until transition/upgrade is finished - no 'backies' ... no 'oops'! ... no 'I forgot this little thing ...' ( ... little things are many times not so little!) :|

And the other take away ... thank goodness this one you knew ... backup ... backup ... backup.  Through the march be sure to do a backup of DB and code (moodledata changes very little if at all ... only caches) so one doesn't loose ground if hickup happens ... and we all know, hickups can happen!  But you've had practice (groan) so no hickups ... right smile

'SoS', Ken



Average of ratings: Useful (1)
In reply to Ken Task

Re: Importing 2.9 DB backup to 3.5 moodle version

by Joel Mendoza -

I'm not so lucky enough Ken mixed I didn't touch 3.6 code or database, but I touched moodledata/filedir. Now even my working site is not working for some local plugins.

Now a new challenge appears: could I rebuild filedir folder for my current and "working" moodle?. Something tell me I will have a veeery long weekend starting from scratch.

Regards,

Joel

In reply to Joel Mendoza

Re: Importing 2.9 DB backup to 3.5 moodle version

by Ken Task -
Picture of Particularly helpful Moodlers

Plus 1 for @Visvanath Ratnaweera response.

Can't 'rebuild' moodledata/filedir ... could restore ... if you had a backup that matched sql dump - but not 'rebuild' just from metadata in DB.

So ... bottom line ... start over!

This might be even more painful .... during the march didn't you have to upgrade PHP and MySQL (maybe tweak DB settings for character set collations)?

IF, on the new server, you did that upgrade to PHP one might need now to 'downgrade' PHP so the cloned 2.9.x can run.

You mentioned plugins ... sounds like you needed to do some advanced research on plugin versions compat with destination version of Moodle. Hint: theme's are plugins and there have been (again) some major changes to themes! :\

Be looking for contact at your addie!

'SoS', Ken




In reply to Ken Task

Re: Importing 2.9 DB backup to 3.5 moodle version

by Joel Mendoza -
Yup, all you mentioned was done and now should be done again. I'm on that.
In reply to Joel Mendoza

Re: Importing 2.9 DB backup to 3.5 moodle version

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Did you read https://docs.moodle.org/en/Moodle_migration ?

The three components,
1. moodle/ (the code directory)
2. moodledata/ (basically the uploaded files in ./filedir/)
3. the database (extracted as a SQL dump with mysqldump, for example)
are tightly connected. You may be able to reconstruct moodle/ from its sources, but for sure not modify moodledata/ to match a given dbdump (or the other way).
In reply to Visvanath Ratnaweera

Re: Importing 2.9 DB backup to 3.5 moodle version

by Joel Mendoza -
Thanks for clarification Visvanath. You confirm I made a mistake and now is time for fix everything from scratch.
In reply to Joel Mendoza

Re: Importing 2.9 DB backup to 3.5 moodle version

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Unless the changes are just in a couple of courses - in which case you might get away with exporting the courses from original site with user data and importing into new site...just a thought...
In reply to Joel Mendoza

Re: Importing 2.9 DB backup to 3.5 moodle version

by Ken Task -
Picture of Particularly helpful Moodlers

Info/update ... have been granted access.

Site now using git.

In process of restoring to 2.9.x - this time with git.

As soon as Joel gets an edited sql dump (search/replace) loaded, restore should take place ... and since now under git should be able to march it forward more easily now.

Plus, op now has a backup script ... code, db, minimal moodledata.

Kinda tough when former hosting gives you a DB dump and tar ball of data directory - no code.

Hey Moodle HQ!!!!   Anyone listening ... suggestion ... include hidden git directory for the version folks are getting via zip/tar.gz.  MP's y'all are missing out on a lot of 'fun'! :|

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Importing 2.9 DB backup to 3.5 moodle version

by Joel Mendoza -
You saved my job Ken! With your help I'm now back on 3.5 with data from 2.9. A lot of time saved and several learned lessons in a couple of days.

Thanks also to Visvanath and Emma, your contributions were appreciated to fix my issues. Now is my turn to return back all this help to the community.

Have a great day like me smile

Joel.
In reply to Joel Mendoza

Re: Importing 2.9 DB backup to 3.5 moodle version

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

You are welcome! Mine was just a hint. But Ken's work goes way beyond the common "I like" click - I hope!