Error when backing up a course

Error when backing up a course

by Dale Vanderhoof -
Number of replies: 15

I have a Moodle site on a shared host using cPanel. I have tried to backup a course and it stops at about 95% and throws the error "Error reading from database". I can turn on debugging, but a stupid question: where do I access the created error logs so that I can upload them here?

I don't think my course is large. I have read other threads and have done some of the things mentioned in them:

  • I checked the moodledata>temp>backup folder and have the zero-length .log files, but there are corresponding folders with the same filenames with no .mbz files anywhere.
  • I deleted all the files in the moodledata>temp>backup folder and tried again. No luck.
  • I tried to see if I could restore the newly-created course, but it it can't be found (which makes sense, since there are no .mbz files).

I have read about changing some of the database settings, but do not, as far as I can see, have access to the database config. files through cPanel.

Any ideas?

Average of ratings: -
In reply to Dale Vanderhoof

Re: Error when backing up a course

by Ken Task -
Picture of Particularly helpful Moodlers

With debugging turned on it's supposed to show the errors right in the Moodle UI - text, from which you could copy and paste into a text editor ... to scrub what might be URL's ... and doctor it so that you don't disclose too much info, then come back here to post the scrubbed info.

Think the key here might be ...  'shared hosting'.   Me thinks Moolde on shared hosting days are all but over.  Newer versions of Moodle requiring additional server software to install to get fully functioning feature in higher versions that providers of shared hosting cannot do/will not do.

Suggest you review your shared hosting plan and whatever upward options exist for you with that provider.   Some shared hosting packages have CAPS ... if the DB part of the backup for example is over those CAPS, shared host configured to kill scripts ... and not report any error.

If you get no debugging output, your plan might be one of those.

'spirit of sharing', Ken

In reply to Dale Vanderhoof

Re: Error when backing up a course

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Dale, consider trying a couple things.

1) When you do a course backup, exclude "enrolled users" from the backup.  This is on the first screen.

2) Consider creating a brand new course, call it something like "Experiment," put ... oh, maybe one forum, one quiz, or one assignment into it, then back it up.  See if your system can backup a very small course.

3) Have you ever made changes to php.ini?  There are a few variables that might needed tweaking.

In reply to Rick Jerz

Re: Error when backing up a course

by Dale Vanderhoof -

>1) When you do a course backup, exclude "enrolled users" from the backup.  This is on the first screen.

I had already tried to backup the course without the "enrolled users" ticked, and it didn't work.

 

>2) Consider creating a brand new course, call it something like "Experiment," put ... oh, maybe one forum, one quiz, or one assignment into it, then back it up.  See if your system can backup a very small course.

I created a course and added a quiz. I then added 1 True/False question to the quiz and tried to back it up. It seemed to work--getting to 100% and telling me that the backup was created successfully. So, is that "good news" or "bad news"? What does that mean?

 

>3) Have you ever made changes to php.ini?  There are a few variables that might needed tweaking.

I searched for "php.ini" and did not find a file by that name. I did find other files ending in .php--one of them being "config.php".

 What next?

In reply to Dale Vanderhoof

Re: Error when backing up a course

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

First, the good news.

1) A backup of a small course succeeds, so your moodle is working fine.

Then, the "bad" news.

2) Since back ups of larger courses fail, you will need to adjust your php.ini settings.  In particular, I suggest change a few of these all at one time so that you may not be bothered again for awhile.  These are:

upload_max_filesize  = 128M

post_max_size  = 128M

memory_limit = 256M

max_input_time  to 600

max_execution_time from to 900

Where do you change these?

1) On some hosted servers, using cPanel, you can change these from within cPanel.

2) In your Moodle, pick Site Administration | Server | PHP Info.  This will tell you on about the 7th line where your php.ini file is.  Now your challenge is to actually change these settings manually, typically using ssh with super user rights.

3) Ask your hosting provider to change these for you.

Who is your hosting company?  Have you talked with them about these changes?

If you find yourself with only #2, then your next step is to get a little smarter?  This type of education will probably take a little while, but is not necessarily hard.  I think that I show how one way to do this on my first video on my Moodle Notes webpage.

In reply to Rick Jerz

Re: Error when backing up a course

by Dale Vanderhoof -
My hosting company id Webhostingbuzz and I found out that I can change

these settings myself, so I changed the settings to the following:



upload_max_filesize  = 512M



post_max_size  = 128M



memory_limit = 512M



max_input_time  to 600



max_execution_time to 900



Then I tried another backup and it failed again with the same message!
In reply to Dale Vanderhoof

Re: Error when backing up a course

by Ken Task -
Picture of Particularly helpful Moodlers

Ok, settings you changed aside ...

We've gotten one question answered ... where hosted ...

According to:
http://www.webhostingbuzz.com/wiki/technical-faq/

Is RAM limited on your shared hosting plans?
According to our AUP
No script or piece of software may use 25% or more of system resources
for 60 seconds or longer
System resources also include RAM, CPU, MySQL (the number of queries and
the time period, during which one query is being performed).

You've mentioned a shared server ... mind disclosing what shared hosting plan?

Have you been able to turn on debugging?   IF so, what, if anything, showed in debugging a backup of a course?

Have you checked out other articles in http://www.webhostingbuzz.com/wiki/ OR contacted helpdesk at webhsstingubzz to see what they can see/say?

'spirit of sharing', Ken

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

Re: Error when backing up a course

by Dale Vanderhoof -
Thanks for the help so far!



I have the "Silver" plan. I have contacted them to see what can be done,

and am waiting to hear from them. I will be out of the state for a few

days, so I may not be able to get back with you with an update until

next week.



Even if I were to update to a Moodle host, how can I get it transferred

over if I do not have a way of backing everything up? Could it be

something else is causing the problem? I am not against hosting

something myself and am not afraid of such a thing but do not want to do

this "full time". as I have a one-man business and need to have time to

do that. That is why I was wanting someone else to do it. I would not

even know where to start. When I read on the forums, etc., it looks like

it is a complicated, very time-consuming mess.



I haven't still been able to turn on debugging, but will keep trying to

figure it out.



I did notice, according to the "Stats" page for the hosting, that the

disk usage is at 92%! That may be the issue also. I notified them of

this and will see what happens...





-Dale
In reply to Dale Vanderhoof

Re: Error when backing up a course

by Ken Task -
Picture of Particularly helpful Moodlers

The only Silver Plan I can find is a VPS

http://www.webhostingbuzz.com/wiki/which-vps-choose/

Debugging - you've not mentioned version of Moodle?

Site Admin Menu -> Development -> Debugging

Pick list at top ... set to Developer.

** remember where you turned this on as after gathering any debugging output you'd want to turn it off **

See attached pic.

Then try a backup again.  IF the system doesn't kill the script, Moodle might be able to report something.

Again ... remember to turn off debugging when done debugging.  Don't leave it on!!!!

Desire not to be or learn how to administer a Moodle server ... you have options .... am certain a Moodle Partner might pop in here and suggest ... or others might suggest Moodle Cloud ... or even others will tell you you can learn ... with their method (good/bad/inbetween).  If thinking about moving upwards or to another hosting solution, the devil is in the details ... research/ask questions ... no matter how stupid they might seem - you don't know what you don't know, so how else would one make the 'best decision'.   Catch 22 to that since you already have a site ... in order to know one has to gather information about what you have now - no tool to do that ... nice summation.  But the data is there in places.   You have to compile it yourself in whatever you have to do such things.

As far as waiting too much longer ... site sounds like it has a good problem in that it's being used ... but if you reach those max's ... problems ... hopefully no so serious that they couldn't be corrected ... with better hosting plan *and* rolling up your sleeves to resolve them.   That's the nature of DIY (do it yourself).   Only you can decide what's best for you ... time wise, $ wise, etc..

As far as guessing any further, advise waiting to hear back from provider.

'spirit of sharing', Ken

Attachment Screen Shot 2017-04-27 at 8.50.15 AM.png
In reply to Ken Task

Re: Error when backing up a course

by Dale Vanderhoof -

I was able to finally get the debugging to work! I tried a backup and it failed. Here is the Stack Trace:

Stack trace:

  • line 479 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1175 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1551 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1624 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1834 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 477 of /backup/util/dbops/backup_controller_dbops.class.php: call to moodle_database->count_records_sql()
  • line 1771 of /backup/moodle2/backup_stepslib.php: call to backup_controller_dbops::backup_includes_mnet_remote_users()
  • line 88 of /backup/util/plan/backup_structure_step.class.php: call to backup_main_structure_step->define_structure()
  • line 181 of /backup/util/plan/base_task.class.php: call to backup_structure_step->execute()
  • line 177 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
  • line 120 of /backup/util/plan/backup_plan.class.php: call to base_plan->execute()
  • line 322 of /backup/controller/backup_controller.class.php: call to backup_plan->execute()
  • line 136 of /backup/util/ui/backup_ui.class.php: call to backup_controller->execute_plan()
  • line 131 of /backup/backup.php: call to backup_ui->execute()
In reply to Dale Vanderhoof

Re: Error when backing up a course

by Ken Task -
Picture of Particularly helpful Moodlers

Hmmm ... one bug report above and one more below - for Rick?

How about it Rick?

Would you concur that this: 'MySQL server has gone away' is the culprit?

That has to do with max_allowed_packets ... a setting for MySQL ... which you, Dale, might not have the ability to set/increase on a shared host.

Check with help desk of provider ... show them the report shared to Rick.   Inquire.

'spirit of sharing', Ken


In reply to Dale Vanderhoof

Re: Error when backing up a course

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I think that so far we know that small courses backup, big courses do not.  Somewhere, there is some resource that is constraining the bigger course backups.  We just need to find it.  We are off "fishing" a little.

Try setting max_execution_time to 2000.

Also, in Moodle, have you verified that your php.ini settings have taken effect?  Go to Site Admin | Server | php settings, and make sure that the setting changes that you have made are actually showing in the php settings.

In reply to Rick Jerz

Re: Error when backing up a course

by Dale Vanderhoof -

> have you verified that your php.ini settings have taken effect?

Yes. I made changes and then checked at the php settings page and the changes were reflected there.

I increased the max_execution_time to 2000 and tried another backup.It still threw the error. Here is the debug info:

Debug info: MySQL server has gone away
SELECT COUNT(*)
FROM see_backup_ids_temp b
JOIN see_user u ON u.id = b.itemid
WHERE b.backupid = ?
AND b.itemname = 'userfinal'
AND u.mnethostid != ?
[array (
0 => 'a5a6bc2d824c0148e0a35dc516baa962',
1 => '1',
)]
Error code: dmlreadexception

 

And here is the Stack Trace:

Stack trace:

  • line 479 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1175 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1551 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1624 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1834 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 477 of /backup/util/dbops/backup_controller_dbops.class.php: call to moodle_database->count_records_sql()
  • line 1771 of /backup/moodle2/backup_stepslib.php: call to backup_controller_dbops::backup_includes_mnet_remote_users()
  • line 88 of /backup/util/plan/backup_structure_step.class.php: call to backup_main_structure_step->define_structure()
  • line 181 of /backup/util/plan/base_task.class.php: call to backup_structure_step->execute()
  • line 177 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
  • line 120 of /backup/util/plan/backup_plan.class.php: call to base_plan->execute()
  • line 322 of /backup/controller/backup_controller.class.php: call to backup_plan->execute()
  • line 136 of /backup/util/ui/backup_ui.class.php: call to backup_controller->execute_plan()
  • line 131 of /backup/backup.php: call to backup_ui->execute()

 

In reply to Dale Vanderhoof

Re: Error when backing up a course

by Just H -

post_max_size should be at least the same as upload_max_filesize (a bit higher can help).

In reply to Just H

Re: Error when backing up a course

by Dale Vanderhoof -

The max I can set the "post_max_size" to is 128M. The max for the "upload_max_filesize" is 1G.

They were set at the following: "post_max_size" = 128M and "upload_max_filesize" = 512M. So I set them bot at 128M

 

I then performed a backup and it threw the error:

Here is the Debug info and Stack Trace:

Debug info: MySQL server has gone away
SELECT COUNT(*)
FROM see_backup_ids_temp b
JOIN see_user u ON u.id = b.itemid
WHERE b.backupid = ?
AND b.itemname = 'userfinal'
AND u.mnethostid != ?
[array (
0 => 'b8bdfedb058bf6a72d605c7fb3d3a5f4',
1 => '1',
)]
Error code: dmlreadexception

 

Stack trace:

  • line 479 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1175 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1551 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1624 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1834 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 477 of /backup/util/dbops/backup_controller_dbops.class.php: call to moodle_database->count_records_sql()
  • line 1771 of /backup/moodle2/backup_stepslib.php: call to backup_controller_dbops::backup_includes_mnet_remote_users()
  • line 88 of /backup/util/plan/backup_structure_step.class.php: call to backup_main_structure_step->define_structure()
  • line 181 of /backup/util/plan/base_task.class.php: call to backup_structure_step->execute()
  • line 177 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
  • line 120 of /backup/util/plan/backup_plan.class.php: call to base_plan->execute()
  • line 322 of /backup/controller/backup_controller.class.php: call to backup_plan->execute()
  • line 136 of /backup/util/ui/backup_ui.class.php: call to backup_controller->execute_plan()
  • line 131 of /backup/backup.php: call to backup_ui->execute()

 

In reply to Dale Vanderhoof

Re: Error when backing up a course

by Ken Task -
Picture of Particularly helpful Moodlers

"I have tried to backup a course and it stops at about 95% and throws the error "Error reading from database". I can turn on debugging, but a stupid question: where do I access the created error logs so that I can upload them here?"

Debugging output if set to developer (which is max) should display to the screen.   Fact that the error says 'reading from database', suggest to me that the shared hosting plan you have isn't allowed to complete the job.   I'll say it again ... check with hosting provider about the details ... maxes ... your shared package/server will allow for all customers on that single system.

In moodledata/temp/backup/  there might be a .log file *like* (not exactly):

91dd4c4875a77ff2ac028cd3811f90ec.log

If the file is 0 bytes in size that course backup was successful.   If the file is larger than 0 bytes it will have a running log of the entire backup process, but it will not be useful ... other than to show at what stage in the plan to backup failed - if 700 is the highest number you see in that log ... it did not succeed (duh!) ... succesful plans reach  1000 ... and the log file will show 0 bytes in size.

There is also evidence of a failed backup that actually might have completed but could not complete the very last step - which is to *copy* (not move) the backup file to the sea of files in filedir of moodledata.  The *copy* command might actually spike resources your shared hosting plan is allowed to use.

Evidence is a long directory name: *like* 91dd4c4875a77ff2ac028cd3811f90ec.

if you look in there and see a .mbz file then the backup failed at the very last stage ... which is copying the backup.mbz file to the sea of files in /moodledata/filedir/

*** IF on a shared plan *** it could be you cannot change nor go over maximums set on your account because of the package purchased.   Some of those maximums might be time for a php script to run ... default is 30 seconds in php ... others might be memory a script can consume.   In the actual code of the backup routine, Moodle attempts to get 128 Megs more memory to do the backup.

*** IMPORTANT *** if Moodle cannot acquire the memory or time needed and you cannot set those variables beyond what you package purchased set no amount of tweaking/cussing/begging with Helpdesk folks will help.

Those 'dirty little secrets' can usually be found in customer forums (to which the the public does not have access).   Have seen helpdesk folks from providers expose those maxes.   And, of course, recommend to the user upgrading from 'shared hosting' to a VPS so that you, the op, can set higher parameters an run higher versions of Moodle.

You can go down rabbit holes pretty easily following advice based upon no knowledge of un-known setups.

'spirit of sharing', Ken