I am trying to perform a backup of the course in Moodle 4.4 version. From last 7 days it is in Process Pending state. I have taken following steps toi resolve the issue:
1. Run the cron job manually - When I run the cron job there is no progress and the backup process is still in pending state.
2. Deleted all the pending tasks from mdl_backup_controllers : After i did this all the tasks that were in pending state got erased from my UI. After that I put the backup again for the course. It has been 4 days and the process is still in the pending state.
3. I have tried taking the backup without the Question bank , enrolled users and all the videos that were present in the course. Even that backup task is in the pending state.
What should i do now? My course is quite big with around 2000 users and multiple videos of around half to one hour each . How can i resolve the issue and take the backup now ?
The other table to truncate mdl_task_adhoc as that is a tracker of the background backup processes.
In code/admin/cli/ there is a backup.php script. Suggest running that script with parameters to save the course backup to a destination outside of moodledata/filedir/ and use a command line 'nohup' wrapper (no hangup).
So that command issued from code/admin/cli/ would look like:
nohup php backup.php --courseid=2 --destination=/moodle/backup/ & [ENTER]
Your command line prompt will come back and you could log out then but ... you might want to stay and watch progress a little bit.
CourseID the id of your large course. You manually create the destination directory. The nohup & wrapper will put the command in a no hang up wrapper and execute until completed. It logs to a file 'nohup.out' at that location and you could watch it's progress via:
tail -f ./nohup.out
Or from command line, in your moodledata/temp/backup/ directory a contenthash named directory will be created to build the backup .mbz file and you could continually ls -l inside that directory to see activity.
In the GUI, in the cateogry of courses where those are located, there should be a listing of those pending and there should be a trashcan. Click the trashcan to remove it from the listing.
While the GUI says one can move onto other things, think it's been discovered that in reality a user may have only one of those running at a time.
All in all, best to use command line for large courses like that. Good luck!
'SoS', Ken
nohup php backup.php --courseid=* --destination=*
Now I am trying to restore that course using the same backup .mbz file generated above through UI. As I am trying to upload the .mbz file in the Restore Course section I am getting the Error "Error connecting to the server". To resolve this issue I have made the changes to my php.ini file in the following fields to support the restore of .mbz file that was of size ~160 MB.
upload_max_filesize = 512M
post_max_size = 512M
max_execution_time = 600
max_input_time = 600
memory_limit = 512M
However still the Error "Error connecting to the server" persists in the Restore file section. How can I now restore the course from UI ? Is there a command to restore the course from CLI just like the backup command? What is the reason of the error "Error connecting to the server" and way to resolve it ?
in code/admin/cli/ there is a restore_backup.php script.
Help on that file shows:
Restore backup into provided category or course.
If courseid is set, course module/s will be added into the course.
Options:
-f, --file=STRING Path to the backup file.
-c, --categoryid=INT ID of the course category to restore to. This option is ignored when restoring an activity and courseid is set.
-C, --courseid=INT ID of the course to restore to. This option is ignored when restoring a course and the categoryid is set.
-s, --showdebugging Show developer level debugging information
-h, --help Print out this help.
Example:
$sudo -u www-data /usr/bin/php admin/cli/restore_backup.php --file=/path/to/backup/coursebackup.mbz --categoryid=1
path to backup is a the location of the .mbz file you made using the backup.php script. No need to download and upload.
A question though, is the purpose of this to prepare that course for use without current users and their work ... ie, a blank course?
If so, since you have an .mbz file (backup) that should cover your records retention policy. Instead of restoring the same course, reset the current course removing all student work and student users ... leaving the teacher of the course and all the content of that course.
'SoS', Ken
php restore_backup.php --showdebugging --file=/path/to/moodle-backup/backup-moodle2-course.mbz --categoryid=2
However it terminated with the following error:
== Extracting backup file to: /var/moodledata/temp/backup/48a8c99757e8af83f69b95c85d05bca6 ==
== Preprocessing backup file ==
instantiating restore controller 0049828e7ee4410dab2f04aa529851da
setting controller status to 100
loading backup info
loading controller plan
setting controller status to 300
applying restore defaults
Unknown setting: questionbank
setting controller status to 400
checking plan security
setting controller status to 600
saving controller to db
calculating controller checksum bec5cdce1663034d3650f67602ea04ff
loading controller from db
instantiating restore controller 02483828a5862da33f8020ae59e5ffe3
setting controller status to 100
loading backup info
loading controller plan
setting controller status to 300
applying restore defaults
Unknown setting: questionbank
setting controller status to 400
checking plan security
setting controller status to 600
saving controller to db
calculating controller checksum 4895e59d7024885107c78e27f14072c6
loading controller from db
== Cleaning temp data ==
Default exception handler: Exception - error/restore_not_executable_awaiting_required Debug:
Error code: generalexceptionmessage
line 156 of /admin/cli/restore_backup.php: core\exception\moodle_exception thrown
!!! Exception - error/restore_not_executable_awaiting_required !!!
!!
Error code: generalexceptionmessage !!
!! Stack trace: * line 156 of /admin/cli/restore_backup.php: core\exception\moodle_exception thrown
!!
The backup .mbz file was created from Moodle having Following Environment :
Moodle Version : 4.1.6
PHP Version : 8.0.30
And I am trying to restore the file in the Moodle having Following Environment :
Moodle Version : 4.5.5
PHP Version : 8.3.22
Is this the reason of error. If no , why is my restore failing and how can i fix it ?
In the debug ... "Unknown setting: questionbank".
In the debug, appears new server is missing an addon?
On old server from code/admin/cli/
php uninstall_plugins.php --show-contrib
That will list the addons installed on the old server.
On the new server, install all the addons before attempting
restore of course backups from old server. Might be missing a question type.
In worse case senario, something is wrong with the questionbank for that course on old server thus backups would have those issues.
To see if that's the case install on old server:
https://moodle.org/plugins/tool_health
and run it. Might find issues with the questionbank and those won't be fixed on the fly when restoring to new server. Let's hope that's not the case!
'SoS', Ken
However there is one difference between the orignal course and the restored course. My orignal course had in the Reports Section "Insights Report" that contained the details of the students and the details of their last access of the course. But in the restored course this Insights Report is not present.
How can i get the Insights report in my restored course as well?
Check site wide backup preferences to assure what gets included in a backup is what you want.
'SoS', Ken