I am in a situation where I have a "live" moodle installation and another "morning copy" moodle installation which serves as a backup. The backup installation is created by syncing all var/moodledata files plus dumping and restoring the moodle database replacing the url path in the sql dump.
After accidentally unenroling users from the live platform and re-enroling them we notice dthat the user's completed activities are not all restored (quiz mostly).
I decided to completely backup a course from the morning copy platform and try to restore it to the live one by transfering the backup file. The backup hangs because the file was larger than 1GB and I had to adjust php_max_execution_time to manage to complete the backup succesfully.
I then noticed that there is no option to restore a backup file from the server's file storage system and that I couldn't possibly download and re-upload 1GB to the same server from a dsl line so I decided to look for the file.
To another surprise I had to searche the mdl_files db table for the "filename" column and find the related "contenthash" so I can locate the filke on the disk. Then I also created a backup on the live platform and located the backup file inside the moodledata filedir, copying one backup to another using the contenthashes of the two platforms.
After that I tried to restore the course backup over the existing course replacing everything and as a result I got an error "error_question_hint_missing_in_db" after 10 minutes (I guess that's how long it took to unzip the backup) which as I understood has something to do with quizzes.
So I gave up trying to restore the course and just replaced the completed user activities in my course using sql. For anyone interested to do so you can export and import the below queries using phpmyadmin, creating .sql files (in the below example this export completed activites, quiz etc for course id's 6,140,69,70)
I then decided to use "moosh" command line tool, which can backup and restore a course from cli on the same server but that also failed giving other bug errors.
ex. "moosh course-backup 6" saves full backup to file default.mbz on server and then you can do a moosh "course-restore -e default.mbz 6" on another installation.
SELECT * FROM `mdl_course_completions` WHERE `course` in (6,140,69,70) ORDER by id ASC
SELECT * FROM `mdl_course_modules` WHERE `course` in (6,140,69,70) ORDER by id ASC
SELECT * FROM `mdl_course_modules_completion` WHERE `coursemoduleid` in (SELECT id FROM `mdl_course_modules` WHERE `course` in (6,140,69,70) ORDER by id ASC)
I am very frustrated as much as tired, is there any way to make this whole "backup large course/restore large course including everything to same server on another copy db" safer, faster and definately easier?