https://docs.moodle.org/19/en/api.php?action=feedcontributions&user=Sylvaticus&feedformat=atomMoodleDocs - User contributions [en]2024-03-28T21:42:52ZUser contributionsMediaWiki 1.39.6https://docs.moodle.org/19/en/index.php?title=Debugging&diff=82840Debugging2011-04-18T09:33:33Z<p>Sylvaticus: </p>
<hr />
<div>Location: <br />
''Administration > Development > Debugging'' (Moodle 2.x) - ''Administration > Server > Debugging'' (Moodle 1.x)<br />
<br />
Debugging messages are intended to help diagnose problems and/or help Moodle developers. If you have a problem with your Moodle site and ask for help in a Moodle.org forum, a developer may ask you to turn debug messages on, in order to locate the cause of the problem. By default Moodle does not show any error messages at all. If you are having problems (e.g. blank screens or incomplete screens) turning on debugging is usually the first thing to try. <br />
<br />
==How to turn on debugging==<br />
<br />
Go into the admin screens, and look under Administration > Server > Debugging (In Moodle 2.0 it is Site administration ▶ Development ▶ Debugging). Set the...<br />
<br />
* '''Debug messages''' to '''ALL''', and <br />
* '''Display debug messages''' to '''Yes'''.<br />
<br />
(You '''must''' do both). There is rarely any advantage in going to Developer level, unless you are a developer, in which case it is strongly recommended.<br />
<br />
Once you have got the error message, and copied and pasted it somewhere, you are recommended to turn debugging back off again.<br />
<br />
==Debug messages==<br />
<br />
{{Moodle 1.7}}From Moodle 1.7 onwards, further options are provided for controlling how to handle PHP error messages. The administrator can select the types of error messages to be displayed or logged. <br />
<br />
The options for debugging include:<br />
* NONE: Do not show any errors or warnings<br />
* MINIMAL: Show only fatal errors<br />
* NORMAL: Show errors, warnings and notices<br />
* ALL: Show all reasonable PHP debug messages. When you want to find the cause of a problem with your site, this is probably best the setting to use.<br />
* DEVELOPER: extra Moodle debug messages for developers - If you turn this on, then PHP's error_reporting will be increased so that more warnings are printed. This is almost essential for developers, but not very helpful for anyone else.<br />
<br />
==Display debug messages==<br />
<br />
There is an option to choose whether to display error messages or simply record them in the server logs.<br />
<br />
==Debug email sending==<br />
<br />
Determines whether or not to enable verbose debug information during sending of email messages to SMTP server.<br />
<br />
==Performance info==<br />
<br />
The Performance info option determines whether performance info will be included in the footer of the standard theme (and some other themes). Performance info includes the time for the page to load, the amount of memory used to generate the page, cpu usage, load, and the record cache hit/miss ration.<br />
<br />
If you add<br />
<code php><br />
define('MDL_PERF', true);<br />
define('MDL_PERFDB', true);<br />
define('MDL_PERFTOLOG', true);<br />
define('MDL_PERFTOFOOT', true);<br />
</code><br />
to your config.php file, then it will also count database queries. (This has to be in config.php, because Moodle starts doing DB queries before it loads the config information in the database!<br />
<br />
==What to do if you cannot get to the admin screens==<br />
<br />
If the error is stopping you even getting to the admin screens to turn on debugging, then you can set the debugging setting manually.<br />
<br />
===Try typing the URL directly===<br />
<br />
The debug settings are at the URL <code><nowiki>http://.../admin/settings.php?section=debugging</nowiki></code> on your server. Sometimes that URL will work, even though the pages you need to go to to get there (for example the site front page) do not. So it is worth trying to enter that URL directly.<br />
<br />
===In config.php===<br />
<br />
In moodle/config.php you can add the lines:<br />
<br />
<code php><br />
$CFG->debug = 2047; <br />
$CFG->debugdisplay = 1;<br />
</code><br />
<br />
Or even more debugging messages:<br />
<br />
<code php><br />
$CFG->debug = 6143; <br />
$CFG->debugdisplay = 1;<br />
</code><br />
<br />
{{Moodle 2.0}}For Moodle 2.0 the possible settings are as follows:<br />
<br />
<code php><br />
// Force a debugging mode regardless the settings in the site administration<br />
// @error_reporting(1023); // NOT FOR PRODUCTION SERVERS!<br />
@ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!<br />
$CFG->debug = 38911; // DEBUG_DEVELOPER // NOT FOR PRODUCTION SERVERS!<br />
$CFG->debugdisplay = true; // NOT FOR PRODUCTION SERVERS!<br />
<br />
// You can specify a comma separated list of user ids that that always see<br />
// debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay<br />
// for these users only.<br />
$CFG->debugusers = '2';<br />
</code><br />
<br />
Remember to remove those lines again when you have finished diagnosing your problem.<br />
<br />
===In the database===<br />
<br />
Using a tool like phpMyAdmin, execute the following SQL commands:<br />
<br />
<code sql><br />
UPDATE mdl_config SET value = 2047 WHERE name = 'debug';<br />
UPDATE mdl_config SET value = 1 WHERE name = 'debugdisplay';<br />
</code><br />
<br />
To turn it back off, use the admin screens, or the commands:<br />
<br />
<code sql><br />
UPDATE mdl_config SET value = 0 WHERE name = 'debug';<br />
UPDATE mdl_config SET value = 0 WHERE name = 'debugdisplay';<br />
</code><br />
<br />
(If you use a different database prefix, you will need to adjust those commands accordingly.)<br />
<br />
==See also==<br />
<br />
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=91031 Debugging Turned on to Developer Mode on 1.8.2] forum discussion including instructions on how to turn debugging off<br />
<br />
[[Category:Administrator]]<br />
<br />
[[fr:Débogage]]</div>Sylvaticushttps://docs.moodle.org/19/en/index.php?title=Debugging&diff=82839Debugging2011-04-18T09:31:39Z<p>Sylvaticus: debugging is under development, not under server</p>
<hr />
<div>Location: ''Administration > Development > Debugging''<br />
<br />
Debugging messages are intended to help diagnose problems and/or help Moodle developers. If you have a problem with your Moodle site and ask for help in a Moodle.org forum, a developer may ask you to turn debug messages on, in order to locate the cause of the problem. By default Moodle does not show any error messages at all. If you are having problems (e.g. blank screens or incomplete screens) turning on debugging is usually the first thing to try. <br />
<br />
==How to turn on debugging==<br />
<br />
Go into the admin screens, and look under Administration > Server > Debugging (In Moodle 2.0 it is Site administration ▶ Development ▶ Debugging). Set the...<br />
<br />
* '''Debug messages''' to '''ALL''', and <br />
* '''Display debug messages''' to '''Yes'''.<br />
<br />
(You '''must''' do both). There is rarely any advantage in going to Developer level, unless you are a developer, in which case it is strongly recommended.<br />
<br />
Once you have got the error message, and copied and pasted it somewhere, you are recommended to turn debugging back off again.<br />
<br />
==Debug messages==<br />
<br />
{{Moodle 1.7}}From Moodle 1.7 onwards, further options are provided for controlling how to handle PHP error messages. The administrator can select the types of error messages to be displayed or logged. <br />
<br />
The options for debugging include:<br />
* NONE: Do not show any errors or warnings<br />
* MINIMAL: Show only fatal errors<br />
* NORMAL: Show errors, warnings and notices<br />
* ALL: Show all reasonable PHP debug messages. When you want to find the cause of a problem with your site, this is probably best the setting to use.<br />
* DEVELOPER: extra Moodle debug messages for developers - If you turn this on, then PHP's error_reporting will be increased so that more warnings are printed. This is almost essential for developers, but not very helpful for anyone else.<br />
<br />
==Display debug messages==<br />
<br />
There is an option to choose whether to display error messages or simply record them in the server logs.<br />
<br />
==Debug email sending==<br />
<br />
Determines whether or not to enable verbose debug information during sending of email messages to SMTP server.<br />
<br />
==Performance info==<br />
<br />
The Performance info option determines whether performance info will be included in the footer of the standard theme (and some other themes). Performance info includes the time for the page to load, the amount of memory used to generate the page, cpu usage, load, and the record cache hit/miss ration.<br />
<br />
If you add<br />
<code php><br />
define('MDL_PERF', true);<br />
define('MDL_PERFDB', true);<br />
define('MDL_PERFTOLOG', true);<br />
define('MDL_PERFTOFOOT', true);<br />
</code><br />
to your config.php file, then it will also count database queries. (This has to be in config.php, because Moodle starts doing DB queries before it loads the config information in the database!<br />
<br />
==What to do if you cannot get to the admin screens==<br />
<br />
If the error is stopping you even getting to the admin screens to turn on debugging, then you can set the debugging setting manually.<br />
<br />
===Try typing the URL directly===<br />
<br />
The debug settings are at the URL <code><nowiki>http://.../admin/settings.php?section=debugging</nowiki></code> on your server. Sometimes that URL will work, even though the pages you need to go to to get there (for example the site front page) do not. So it is worth trying to enter that URL directly.<br />
<br />
===In config.php===<br />
<br />
In moodle/config.php you can add the lines:<br />
<br />
<code php><br />
$CFG->debug = 2047; <br />
$CFG->debugdisplay = 1;<br />
</code><br />
<br />
Or even more debugging messages:<br />
<br />
<code php><br />
$CFG->debug = 6143; <br />
$CFG->debugdisplay = 1;<br />
</code><br />
<br />
{{Moodle 2.0}}For Moodle 2.0 the possible settings are as follows:<br />
<br />
<code php><br />
// Force a debugging mode regardless the settings in the site administration<br />
// @error_reporting(1023); // NOT FOR PRODUCTION SERVERS!<br />
@ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!<br />
$CFG->debug = 38911; // DEBUG_DEVELOPER // NOT FOR PRODUCTION SERVERS!<br />
$CFG->debugdisplay = true; // NOT FOR PRODUCTION SERVERS!<br />
<br />
// You can specify a comma separated list of user ids that that always see<br />
// debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay<br />
// for these users only.<br />
$CFG->debugusers = '2';<br />
</code><br />
<br />
Remember to remove those lines again when you have finished diagnosing your problem.<br />
<br />
===In the database===<br />
<br />
Using a tool like phpMyAdmin, execute the following SQL commands:<br />
<br />
<code sql><br />
UPDATE mdl_config SET value = 2047 WHERE name = 'debug';<br />
UPDATE mdl_config SET value = 1 WHERE name = 'debugdisplay';<br />
</code><br />
<br />
To turn it back off, use the admin screens, or the commands:<br />
<br />
<code sql><br />
UPDATE mdl_config SET value = 0 WHERE name = 'debug';<br />
UPDATE mdl_config SET value = 0 WHERE name = 'debugdisplay';<br />
</code><br />
<br />
(If you use a different database prefix, you will need to adjust those commands accordingly.)<br />
<br />
==See also==<br />
<br />
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=91031 Debugging Turned on to Developer Mode on 1.8.2] forum discussion including instructions on how to turn debugging off<br />
<br />
[[Category:Administrator]]<br />
<br />
[[fr:Débogage]]</div>Sylvaticushttps://docs.moodle.org/19/en/index.php?title=Backup_and_restore_FAQ&diff=51741Backup and restore FAQ2009-02-27T11:32:50Z<p>Sylvaticus: /* Restoring a course results in broken HTML tags. What can I do? */</p>
<hr />
<div>==How do I backup a course?==<br />
<br />
See [[Course backup]] and [[Automated course backup]].<br />
<br />
==How do I backup my site?==<br />
<br />
See [[Site backup]].<br />
<br />
==Backup stops at Zipping backup==<br />
Moodle 1.9 and lower use a PHP library to zip files that isn't very efficient and struggles to zip/unzip large files. You can use an external Zip binary to use a different process to handle your files - you can set this in ''Admin > Server > System Paths'' Moodle 2.0 uses new PHP zip functions so that specifying an external Zip binary isn't necessary see [[System_paths#Path_to_zip]] for help configuring an external zip binary.<br />
<br />
==What are the pros and cons of course versus site backups?==<br />
<br />
[[Site backup|Site backups]] are recommended in order to have all data saved with the best confidence and the shortest recovery time.<br />
<br />
[[Automated course backup|Automated course backups]] are more expensive in terms of time and CPU usage. The recovery time to have your site running again is longer. Course backups are useful for obtaining "fresh" copies of courses to be re-used or distributed individually, however they should never be used as a primary backup system (unless your hosting doesn't allow the preferred site backups). <br />
<br />
==What data is not contained in course backups?==<br />
<br />
By selecting all the options when setting up the backup you can include almost all the data in the course. However you should be aware of the fact that some things are not backed up:<br />
* Quiz questions are only backed up if at least one question from their category has been added to a quiz.<br />
* Scales are only backed up if they are used by at least one activity.<br />
<br />
==The process ends with: "Error: An error occurred deleting old backup data". What should I do?==<br />
<br />
This part of the backup (or restore) procedure tries to delete old info, used in previous executions, performing the following tasks:<br />
<br />
# Delete old records from "backup_ids" table: Check the table exists, repair it and try again.<br />
# Delete old records from "backup_files" table: Check the table exists, repair it and try again.<br />
# Delete old files from "moodledata/temp/backup": Delete the dir completely and try again.<br />
<br />
[[Image:BackupProblem.gif|thumb|Backup error message]]For points 1 & 2, there are various ways of repairing tables, including using MySQL Admin.<br />
For point 3 see below:<br />
<br />
The error message states that the "directory not empty" and gives the path to that directory. If you go there with an FTP program you can see what is there and clean up. It could be just some empty subfolders that were leftover. Deleting these has been able to help. One can also delete the dir "moodledata/temp/backup" completely. That can take a bit longer but may solve several problems at once.<br />
<br />
==The process ends with: "XML error: not well-formed (invalid token) at line YYYY". What can I do?==<br />
<br />
This problem can appear at any point in the restore process. It's caused when the XML parser detects something incorrect in the backup file that prevent correct operation. Usually, it's caused by some "illegal" characters added in the original course due to some copy/paste of text containing them (control characters, or invalid sequences...).<br />
<br />
The best method to handle this issue is:<br />
<br />
* Unzip the problematic backup file under one empty folder.<br />
<br />
* Open the moodle.xml with Firefox. It will show you where (exact char) the problem is happening.<br />
<br />
* Edit the moodle.xml file with some UTF8-compatible editor and delete such characters. Save changes.<br />
<br />
* Test the moodle.xml file again with Firefox until no error was displayed.<br />
<br />
* Zip everything again (all the folder contents but not the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
* Restore still not working? See the next question.<br />
<br />
Also, if possible, it's highly recommended to solve those problems in the original course too from Moodle itself. Once "repaired" there, problems will be out if you create new backup files in the future.<br />
<br />
==I Still get an XML error. How can I clean the borked XML file?==<br />
<br />
In some cases XML backup files may contain characters causing the restore process to abort, even after the steps described in the previous question. In such cases you may want to try the following:<br />
<br />
* Download the [http://repository.atlassian.com/atlassian-xml-cleaner/jars/atlassian-xml-cleaner-0.1.jar Atlassian XML Cleaner Utility] from the [http://confluence.atlassian.com/display/JIRA/Removing+invalid+characters+from+XML+backups JIRA Atlassian site].<br />
<br />
* Unzip the problematic Moodle backup file under one empty folder. Moodle will create the course file folders as long as the unclean moodle.xml file. Please unzip using the Moodle unzip feature.<br />
<br />
* Rename the unclean moodle.xml file to moodle-unclean.xml. <br />
<br />
* If you don't have access to your Moodle server's command prompt, using the Moodle zip feature, zip the moodle-unclean.xml file only, download the zip file locally and unzip it. It is very important to download the xml file in zipped format to avoid unwanted character encoding when transferring from an operating system to another.<br />
<br />
* Move the downloaded Atlassian XML Cleaner Utility in the same folder where is your moodle-unclean.xml file.<br />
<br />
* Issue the following command from the command prompt: <br />
<br />
java -jar atlassian-xml-cleaner-0.1.jar moodle-unclean.xml > moodle.xml<br />
<br />
* If you launched the utility on your local computer, zip the just created (and hopefully cleaned) moodle.xml file and upload it in the same place from where you downloaded the moodle-unclean.xml file. Once uploaded, unzip it using the Moodle unzip feature.<br />
<br />
* Zip everything again (all the folder contents but the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
==What does "Some of your courses weren't saved!!" mean?==<br />
<br />
There are three possible causes of this problem:<br />
# Error - this happens when the backup procedure has found an error and so hasn't finished the backup of a particular course. These are "controlled" errors and the scheduled backup continues with the next course.<br />
# Unfinished - this happens when the backup procedure dies without knowing why. When the cron is next executed it detects that the last execution went wrong, and continues skipping the problematic course. A possible solution would be to raise the PHP/Apache limit in your installation (memory, time of execution...). By taking a look to your log tables you should be able to see if the "crash" is happening at exact time intervals (usually a problem with the max_execution_time php's variable), or if there is some exact point were all the courses are breaking (generally internal zip libraries, try to switch to external executables instead).<br />
# Skipped - this happens when a course is unavailable to students and has not been changed in the last month (31 days). This isn't an error situation - it's a feature, especially useful for sites with many unavailable old courses, saving process time.<br />
<br />
==How can I restore pre 1.6 non-ISO-8859-1 backups to Moodle 1.6 (Unicode)?==<br />
<br />
Any backup files with contents which are not 100% ISO-8859-1 will be a problem to restore to Moodle 1.6 (and upwards) running under Unicode. Instead, please try the following:<br />
<br />
# Make a clean install of Moodle 1.5.x (the latest version available)<br />
# Restore all your courses there (they should work if they were working originally)<br />
# Upgrade your site to Moodle 1.6 and run the UTF-8 migration script<br />
# Backup your courses again<br />
<br />
This will produce a new set of backup files that will be 100% UTF-8 and you will be able to use them with Moodle 1.6 without any problems.<br />
<br />
==Restoring a course results in broken HTML tags. What can I do?==<br />
<br />
This problem is due to a [http://bugs.php.net/bug.php?id=45996 PHP bug in libxml2 2.7.1] (the same bug reported with version 2.7.2 and 2.7.3). All HTML entities, such as &gt;, &lt; and &quot; are removed when a course is restored.<br />
<br />
To resolve the problem, you should use a different version of libxml2 such as 2.7.0 or 2.6.32 or compile PHP against libexpat instead of libxml2 or finally use PHP version >= 5.2.9 that solves this compatibility issue over the newer libxml2.<br />
<br />
At Gentoo servers, you can use<br />
<br />
echo ">dev-libs/libxml2-2.6.32" >> /etc/portage/package.mask<br />
<br />
See the discussion [http://moodle.org/mod/forum/discuss.php?d=111321 Restoring makes webpages and labels in code] for further information.<br />
<br />
==Why are some courses being skipped?==<br />
<br />
From 1.6 onwards, course backups automatically skip courses which are unavailable to students and have not been changed in the last month.<br />
<br />
==Why does restore stop, rather than completing?==<br />
<br />
Attempting to restore a course to an older version of Moodle than the one the course was backed up on can result in the restore process failing to complete. To ensure a successful restore, make sure that the version of Moodle you are restoring the course to is the same, or newer, than the one the course was backed up on.<br />
<br />
== See also ==<br />
<br />
*Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum]<br />
*[http://www.databasejournal.com/features/mysql/article.php/10897_3300511_2 databasejournal.com article on repairing database corruption in MySQL]<br />
<br />
Using Moodle forum discussions:<br />
*[http://moodle.org/mod/forum/discuss.php?d=66708 Scheduled backup fails] including possible solution to "An error occurred while copying files".<br />
*[http://moodle.org/mod/forum/discuss.php?d=99338 Restore stops]<br />
<br />
[[Category:FAQ]]<br />
[[Category:Backup]]<br />
<br />
[[es:FAQ Backup]]<br />
[[pl:Backup FAQ]]<br />
[[fr:FAQ de sauvegarde]]<br />
[[ja:バックアップFAQ]]<br />
[[pt:FAQ sobre cópias de segurança]]</div>Sylvaticushttps://docs.moodle.org/19/en/index.php?title=Backup_and_restore_FAQ&diff=51740Backup and restore FAQ2009-02-27T11:32:30Z<p>Sylvaticus: /* Restoring a course results in broken HTML tags. What can I do? */</p>
<hr />
<div>==How do I backup a course?==<br />
<br />
See [[Course backup]] and [[Automated course backup]].<br />
<br />
==How do I backup my site?==<br />
<br />
See [[Site backup]].<br />
<br />
==Backup stops at Zipping backup==<br />
Moodle 1.9 and lower use a PHP library to zip files that isn't very efficient and struggles to zip/unzip large files. You can use an external Zip binary to use a different process to handle your files - you can set this in ''Admin > Server > System Paths'' Moodle 2.0 uses new PHP zip functions so that specifying an external Zip binary isn't necessary see [[System_paths#Path_to_zip]] for help configuring an external zip binary.<br />
<br />
==What are the pros and cons of course versus site backups?==<br />
<br />
[[Site backup|Site backups]] are recommended in order to have all data saved with the best confidence and the shortest recovery time.<br />
<br />
[[Automated course backup|Automated course backups]] are more expensive in terms of time and CPU usage. The recovery time to have your site running again is longer. Course backups are useful for obtaining "fresh" copies of courses to be re-used or distributed individually, however they should never be used as a primary backup system (unless your hosting doesn't allow the preferred site backups). <br />
<br />
==What data is not contained in course backups?==<br />
<br />
By selecting all the options when setting up the backup you can include almost all the data in the course. However you should be aware of the fact that some things are not backed up:<br />
* Quiz questions are only backed up if at least one question from their category has been added to a quiz.<br />
* Scales are only backed up if they are used by at least one activity.<br />
<br />
==The process ends with: "Error: An error occurred deleting old backup data". What should I do?==<br />
<br />
This part of the backup (or restore) procedure tries to delete old info, used in previous executions, performing the following tasks:<br />
<br />
# Delete old records from "backup_ids" table: Check the table exists, repair it and try again.<br />
# Delete old records from "backup_files" table: Check the table exists, repair it and try again.<br />
# Delete old files from "moodledata/temp/backup": Delete the dir completely and try again.<br />
<br />
[[Image:BackupProblem.gif|thumb|Backup error message]]For points 1 & 2, there are various ways of repairing tables, including using MySQL Admin.<br />
For point 3 see below:<br />
<br />
The error message states that the "directory not empty" and gives the path to that directory. If you go there with an FTP program you can see what is there and clean up. It could be just some empty subfolders that were leftover. Deleting these has been able to help. One can also delete the dir "moodledata/temp/backup" completely. That can take a bit longer but may solve several problems at once.<br />
<br />
==The process ends with: "XML error: not well-formed (invalid token) at line YYYY". What can I do?==<br />
<br />
This problem can appear at any point in the restore process. It's caused when the XML parser detects something incorrect in the backup file that prevent correct operation. Usually, it's caused by some "illegal" characters added in the original course due to some copy/paste of text containing them (control characters, or invalid sequences...).<br />
<br />
The best method to handle this issue is:<br />
<br />
* Unzip the problematic backup file under one empty folder.<br />
<br />
* Open the moodle.xml with Firefox. It will show you where (exact char) the problem is happening.<br />
<br />
* Edit the moodle.xml file with some UTF8-compatible editor and delete such characters. Save changes.<br />
<br />
* Test the moodle.xml file again with Firefox until no error was displayed.<br />
<br />
* Zip everything again (all the folder contents but not the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
* Restore still not working? See the next question.<br />
<br />
Also, if possible, it's highly recommended to solve those problems in the original course too from Moodle itself. Once "repaired" there, problems will be out if you create new backup files in the future.<br />
<br />
==I Still get an XML error. How can I clean the borked XML file?==<br />
<br />
In some cases XML backup files may contain characters causing the restore process to abort, even after the steps described in the previous question. In such cases you may want to try the following:<br />
<br />
* Download the [http://repository.atlassian.com/atlassian-xml-cleaner/jars/atlassian-xml-cleaner-0.1.jar Atlassian XML Cleaner Utility] from the [http://confluence.atlassian.com/display/JIRA/Removing+invalid+characters+from+XML+backups JIRA Atlassian site].<br />
<br />
* Unzip the problematic Moodle backup file under one empty folder. Moodle will create the course file folders as long as the unclean moodle.xml file. Please unzip using the Moodle unzip feature.<br />
<br />
* Rename the unclean moodle.xml file to moodle-unclean.xml. <br />
<br />
* If you don't have access to your Moodle server's command prompt, using the Moodle zip feature, zip the moodle-unclean.xml file only, download the zip file locally and unzip it. It is very important to download the xml file in zipped format to avoid unwanted character encoding when transferring from an operating system to another.<br />
<br />
* Move the downloaded Atlassian XML Cleaner Utility in the same folder where is your moodle-unclean.xml file.<br />
<br />
* Issue the following command from the command prompt: <br />
<br />
java -jar atlassian-xml-cleaner-0.1.jar moodle-unclean.xml > moodle.xml<br />
<br />
* If you launched the utility on your local computer, zip the just created (and hopefully cleaned) moodle.xml file and upload it in the same place from where you downloaded the moodle-unclean.xml file. Once uploaded, unzip it using the Moodle unzip feature.<br />
<br />
* Zip everything again (all the folder contents but the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
==What does "Some of your courses weren't saved!!" mean?==<br />
<br />
There are three possible causes of this problem:<br />
# Error - this happens when the backup procedure has found an error and so hasn't finished the backup of a particular course. These are "controlled" errors and the scheduled backup continues with the next course.<br />
# Unfinished - this happens when the backup procedure dies without knowing why. When the cron is next executed it detects that the last execution went wrong, and continues skipping the problematic course. A possible solution would be to raise the PHP/Apache limit in your installation (memory, time of execution...). By taking a look to your log tables you should be able to see if the "crash" is happening at exact time intervals (usually a problem with the max_execution_time php's variable), or if there is some exact point were all the courses are breaking (generally internal zip libraries, try to switch to external executables instead).<br />
# Skipped - this happens when a course is unavailable to students and has not been changed in the last month (31 days). This isn't an error situation - it's a feature, especially useful for sites with many unavailable old courses, saving process time.<br />
<br />
==How can I restore pre 1.6 non-ISO-8859-1 backups to Moodle 1.6 (Unicode)?==<br />
<br />
Any backup files with contents which are not 100% ISO-8859-1 will be a problem to restore to Moodle 1.6 (and upwards) running under Unicode. Instead, please try the following:<br />
<br />
# Make a clean install of Moodle 1.5.x (the latest version available)<br />
# Restore all your courses there (they should work if they were working originally)<br />
# Upgrade your site to Moodle 1.6 and run the UTF-8 migration script<br />
# Backup your courses again<br />
<br />
This will produce a new set of backup files that will be 100% UTF-8 and you will be able to use them with Moodle 1.6 without any problems.<br />
<br />
==Restoring a course results in broken HTML tags. What can I do?==<br />
<br />
This problem is due to a [http://bugs.php.net/bug.php?id=45996 PHP bug in libxml2 2.7.1] (the same bug reported with version 2.7.2 and 2.7.3). All HTML entities, such as &gt;, &lt; and &quot; are removed when a course is restored.<br />
<br />
To resolve the problem, you should use a different version of libxml2 such as 2.7.0 or 2.6.32 or compile PHP against libexpat instead of libxml2 or finally use PHP version >= 5.2.9 that solve this compatibility issue over the newer libxml2.<br />
<br />
At Gentoo servers, you can use<br />
<br />
echo ">dev-libs/libxml2-2.6.32" >> /etc/portage/package.mask<br />
<br />
See the discussion [http://moodle.org/mod/forum/discuss.php?d=111321 Restoring makes webpages and labels in code] for further information.<br />
<br />
==Why are some courses being skipped?==<br />
<br />
From 1.6 onwards, course backups automatically skip courses which are unavailable to students and have not been changed in the last month.<br />
<br />
==Why does restore stop, rather than completing?==<br />
<br />
Attempting to restore a course to an older version of Moodle than the one the course was backed up on can result in the restore process failing to complete. To ensure a successful restore, make sure that the version of Moodle you are restoring the course to is the same, or newer, than the one the course was backed up on.<br />
<br />
== See also ==<br />
<br />
*Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum]<br />
*[http://www.databasejournal.com/features/mysql/article.php/10897_3300511_2 databasejournal.com article on repairing database corruption in MySQL]<br />
<br />
Using Moodle forum discussions:<br />
*[http://moodle.org/mod/forum/discuss.php?d=66708 Scheduled backup fails] including possible solution to "An error occurred while copying files".<br />
*[http://moodle.org/mod/forum/discuss.php?d=99338 Restore stops]<br />
<br />
[[Category:FAQ]]<br />
[[Category:Backup]]<br />
<br />
[[es:FAQ Backup]]<br />
[[pl:Backup FAQ]]<br />
[[fr:FAQ de sauvegarde]]<br />
[[ja:バックアップFAQ]]<br />
[[pt:FAQ sobre cópias de segurança]]</div>Sylvaticushttps://docs.moodle.org/19/en/index.php?title=Backup_and_restore_FAQ&diff=51739Backup and restore FAQ2009-02-27T11:31:24Z<p>Sylvaticus: /* Restoring a course results in broken HTML tags. What can I do? */</p>
<hr />
<div>==How do I backup a course?==<br />
<br />
See [[Course backup]] and [[Automated course backup]].<br />
<br />
==How do I backup my site?==<br />
<br />
See [[Site backup]].<br />
<br />
==Backup stops at Zipping backup==<br />
Moodle 1.9 and lower use a PHP library to zip files that isn't very efficient and struggles to zip/unzip large files. You can use an external Zip binary to use a different process to handle your files - you can set this in ''Admin > Server > System Paths'' Moodle 2.0 uses new PHP zip functions so that specifying an external Zip binary isn't necessary see [[System_paths#Path_to_zip]] for help configuring an external zip binary.<br />
<br />
==What are the pros and cons of course versus site backups?==<br />
<br />
[[Site backup|Site backups]] are recommended in order to have all data saved with the best confidence and the shortest recovery time.<br />
<br />
[[Automated course backup|Automated course backups]] are more expensive in terms of time and CPU usage. The recovery time to have your site running again is longer. Course backups are useful for obtaining "fresh" copies of courses to be re-used or distributed individually, however they should never be used as a primary backup system (unless your hosting doesn't allow the preferred site backups). <br />
<br />
==What data is not contained in course backups?==<br />
<br />
By selecting all the options when setting up the backup you can include almost all the data in the course. However you should be aware of the fact that some things are not backed up:<br />
* Quiz questions are only backed up if at least one question from their category has been added to a quiz.<br />
* Scales are only backed up if they are used by at least one activity.<br />
<br />
==The process ends with: "Error: An error occurred deleting old backup data". What should I do?==<br />
<br />
This part of the backup (or restore) procedure tries to delete old info, used in previous executions, performing the following tasks:<br />
<br />
# Delete old records from "backup_ids" table: Check the table exists, repair it and try again.<br />
# Delete old records from "backup_files" table: Check the table exists, repair it and try again.<br />
# Delete old files from "moodledata/temp/backup": Delete the dir completely and try again.<br />
<br />
[[Image:BackupProblem.gif|thumb|Backup error message]]For points 1 & 2, there are various ways of repairing tables, including using MySQL Admin.<br />
For point 3 see below:<br />
<br />
The error message states that the "directory not empty" and gives the path to that directory. If you go there with an FTP program you can see what is there and clean up. It could be just some empty subfolders that were leftover. Deleting these has been able to help. One can also delete the dir "moodledata/temp/backup" completely. That can take a bit longer but may solve several problems at once.<br />
<br />
==The process ends with: "XML error: not well-formed (invalid token) at line YYYY". What can I do?==<br />
<br />
This problem can appear at any point in the restore process. It's caused when the XML parser detects something incorrect in the backup file that prevent correct operation. Usually, it's caused by some "illegal" characters added in the original course due to some copy/paste of text containing them (control characters, or invalid sequences...).<br />
<br />
The best method to handle this issue is:<br />
<br />
* Unzip the problematic backup file under one empty folder.<br />
<br />
* Open the moodle.xml with Firefox. It will show you where (exact char) the problem is happening.<br />
<br />
* Edit the moodle.xml file with some UTF8-compatible editor and delete such characters. Save changes.<br />
<br />
* Test the moodle.xml file again with Firefox until no error was displayed.<br />
<br />
* Zip everything again (all the folder contents but not the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
* Restore still not working? See the next question.<br />
<br />
Also, if possible, it's highly recommended to solve those problems in the original course too from Moodle itself. Once "repaired" there, problems will be out if you create new backup files in the future.<br />
<br />
==I Still get an XML error. How can I clean the borked XML file?==<br />
<br />
In some cases XML backup files may contain characters causing the restore process to abort, even after the steps described in the previous question. In such cases you may want to try the following:<br />
<br />
* Download the [http://repository.atlassian.com/atlassian-xml-cleaner/jars/atlassian-xml-cleaner-0.1.jar Atlassian XML Cleaner Utility] from the [http://confluence.atlassian.com/display/JIRA/Removing+invalid+characters+from+XML+backups JIRA Atlassian site].<br />
<br />
* Unzip the problematic Moodle backup file under one empty folder. Moodle will create the course file folders as long as the unclean moodle.xml file. Please unzip using the Moodle unzip feature.<br />
<br />
* Rename the unclean moodle.xml file to moodle-unclean.xml. <br />
<br />
* If you don't have access to your Moodle server's command prompt, using the Moodle zip feature, zip the moodle-unclean.xml file only, download the zip file locally and unzip it. It is very important to download the xml file in zipped format to avoid unwanted character encoding when transferring from an operating system to another.<br />
<br />
* Move the downloaded Atlassian XML Cleaner Utility in the same folder where is your moodle-unclean.xml file.<br />
<br />
* Issue the following command from the command prompt: <br />
<br />
java -jar atlassian-xml-cleaner-0.1.jar moodle-unclean.xml > moodle.xml<br />
<br />
* If you launched the utility on your local computer, zip the just created (and hopefully cleaned) moodle.xml file and upload it in the same place from where you downloaded the moodle-unclean.xml file. Once uploaded, unzip it using the Moodle unzip feature.<br />
<br />
* Zip everything again (all the folder contents but the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
==What does "Some of your courses weren't saved!!" mean?==<br />
<br />
There are three possible causes of this problem:<br />
# Error - this happens when the backup procedure has found an error and so hasn't finished the backup of a particular course. These are "controlled" errors and the scheduled backup continues with the next course.<br />
# Unfinished - this happens when the backup procedure dies without knowing why. When the cron is next executed it detects that the last execution went wrong, and continues skipping the problematic course. A possible solution would be to raise the PHP/Apache limit in your installation (memory, time of execution...). By taking a look to your log tables you should be able to see if the "crash" is happening at exact time intervals (usually a problem with the max_execution_time php's variable), or if there is some exact point were all the courses are breaking (generally internal zip libraries, try to switch to external executables instead).<br />
# Skipped - this happens when a course is unavailable to students and has not been changed in the last month (31 days). This isn't an error situation - it's a feature, especially useful for sites with many unavailable old courses, saving process time.<br />
<br />
==How can I restore pre 1.6 non-ISO-8859-1 backups to Moodle 1.6 (Unicode)?==<br />
<br />
Any backup files with contents which are not 100% ISO-8859-1 will be a problem to restore to Moodle 1.6 (and upwards) running under Unicode. Instead, please try the following:<br />
<br />
# Make a clean install of Moodle 1.5.x (the latest version available)<br />
# Restore all your courses there (they should work if they were working originally)<br />
# Upgrade your site to Moodle 1.6 and run the UTF-8 migration script<br />
# Backup your courses again<br />
<br />
This will produce a new set of backup files that will be 100% UTF-8 and you will be able to use them with Moodle 1.6 without any problems.<br />
<br />
==Restoring a course results in broken HTML tags. What can I do?==<br />
<br />
This problem is due to a [http://bugs.php.net/bug.php?id=45996 PHP bug in libxml2 2.7.1] (the same bug reported with version 2.7.2 and 2.7.3). All HTML entities, such as &gt;, &lt; and &quot; are removed when a course is restored.<br />
<br />
To resolve the problem, you should use a different version of libxml2 such as 2.7.0 or 2.6.32 or compile PHP against libexpat instead of libxml2 or finally use PHP version >= 5.2.9<br />
<br />
At Gentoo servers, you can use<br />
<br />
echo ">dev-libs/libxml2-2.6.32" >> /etc/portage/package.mask<br />
<br />
See the discussion [http://moodle.org/mod/forum/discuss.php?d=111321 Restoring makes webpages and labels in code] for further information.<br />
<br />
==Why are some courses being skipped?==<br />
<br />
From 1.6 onwards, course backups automatically skip courses which are unavailable to students and have not been changed in the last month.<br />
<br />
==Why does restore stop, rather than completing?==<br />
<br />
Attempting to restore a course to an older version of Moodle than the one the course was backed up on can result in the restore process failing to complete. To ensure a successful restore, make sure that the version of Moodle you are restoring the course to is the same, or newer, than the one the course was backed up on.<br />
<br />
== See also ==<br />
<br />
*Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum]<br />
*[http://www.databasejournal.com/features/mysql/article.php/10897_3300511_2 databasejournal.com article on repairing database corruption in MySQL]<br />
<br />
Using Moodle forum discussions:<br />
*[http://moodle.org/mod/forum/discuss.php?d=66708 Scheduled backup fails] including possible solution to "An error occurred while copying files".<br />
*[http://moodle.org/mod/forum/discuss.php?d=99338 Restore stops]<br />
<br />
[[Category:FAQ]]<br />
[[Category:Backup]]<br />
<br />
[[es:FAQ Backup]]<br />
[[pl:Backup FAQ]]<br />
[[fr:FAQ de sauvegarde]]<br />
[[ja:バックアップFAQ]]<br />
[[pt:FAQ sobre cópias de segurança]]</div>Sylvaticushttps://docs.moodle.org/19/en/index.php?title=Backup_and_restore_FAQ&diff=51668Backup and restore FAQ2009-02-26T12:33:14Z<p>Sylvaticus: /* Restoring a course results in broken HTML tags. What can I do? */</p>
<hr />
<div>==How do I backup a course?==<br />
<br />
See [[Course backup]] and [[Automated course backup]].<br />
<br />
==How do I backup my site?==<br />
<br />
See [[Site backup]].<br />
<br />
==Backup stops at Zipping backup==<br />
Moodle 1.9 and lower use a PHP library to zip files that isn't very efficient and struggles to zip/unzip large files. You can use an external Zip binary to use a different process to handle your files - you can set this in ''Admin > Server > System Paths'' Moodle 2.0 uses new PHP zip functions so that specifying an external Zip binary isn't necessary see [[System_paths#Path_to_zip]] for help configuring an external zip binary.<br />
<br />
==What are the pros and cons of course versus site backups?==<br />
<br />
[[Site backup|Site backups]] are recommended in order to have all data saved with the best confidence and the shortest recovery time.<br />
<br />
[[Automated course backup|Automated course backups]] are more expensive in terms of time and CPU usage. The recovery time to have your site running again is longer. Course backups are useful for obtaining "fresh" copies of courses to be re-used or distributed individually, however they should never be used as a primary backup system (unless your hosting doesn't allow the preferred site backups). <br />
<br />
==What data is not contained in course backups?==<br />
<br />
By selecting all the options when setting up the backup you can include almost all the data in the course. However you should be aware of the fact that some things are not backed up:<br />
* Quiz questions are only backed up if at least one question from their category has been added to a quiz.<br />
* Scales are only backed up if they are used by at least one activity.<br />
<br />
==The process ends with: "Error: An error occurred deleting old backup data". What should I do?==<br />
<br />
This part of the backup (or restore) procedure tries to delete old info, used in previous executions, performing the following tasks:<br />
<br />
# Delete old records from "backup_ids" table: Check the table exists, repair it and try again.<br />
# Delete old records from "backup_files" table: Check the table exists, repair it and try again.<br />
# Delete old files from "moodledata/temp/backup": Delete the dir completely and try again.<br />
<br />
[[Image:BackupProblem.gif|thumb|Backup error message]]For points 1 & 2, there are various ways of repairing tables, including using MySQL Admin.<br />
For point 3 see below:<br />
<br />
The error message states that the "directory not empty" and gives the path to that directory. If you go there with an FTP program you can see what is there and clean up. It could be just some empty subfolders that were leftover. Deleting these has been able to help. One can also delete the dir "moodledata/temp/backup" completely. That can take a bit longer but may solve several problems at once.<br />
<br />
==The process ends with: "XML error: not well-formed (invalid token) at line YYYY". What can I do?==<br />
<br />
This problem can appear at any point in the restore process. It's caused when the XML parser detects something incorrect in the backup file that prevent correct operation. Usually, it's caused by some "illegal" characters added in the original course due to some copy/paste of text containing them (control characters, or invalid sequences...).<br />
<br />
The best method to handle this issue is:<br />
<br />
* Unzip the problematic backup file under one empty folder.<br />
<br />
* Open the moodle.xml with Firefox. It will show you where (exact char) the problem is happening.<br />
<br />
* Edit the moodle.xml file with some UTF8-compatible editor and delete such characters. Save changes.<br />
<br />
* Test the moodle.xml file again with Firefox until no error was displayed.<br />
<br />
* Zip everything again (all the folder contents but not the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
* Restore still not working? See the next question.<br />
<br />
Also, if possible, it's highly recommended to solve those problems in the original course too from Moodle itself. Once "repaired" there, problems will be out if you create new backup files in the future.<br />
<br />
==I Still get an XML error. How can I clean the borked XML file?==<br />
<br />
In some cases XML backup files may contain characters causing the restore process to abort, even after the steps described in the previous question. In such cases you may want to try the following:<br />
<br />
* Download the [http://repository.atlassian.com/atlassian-xml-cleaner/jars/atlassian-xml-cleaner-0.1.jar Atlassian XML Cleaner Utility] from the [http://confluence.atlassian.com/display/JIRA/Removing+invalid+characters+from+XML+backups JIRA Atlassian site].<br />
<br />
* Unzip the problematic Moodle backup file under one empty folder. Moodle will create the course file folders as long as the unclean moodle.xml file. Please unzip using the Moodle unzip feature.<br />
<br />
* Rename the unclean moodle.xml file to moodle-unclean.xml. <br />
<br />
* If you don't have access to your Moodle server's command prompt, using the Moodle zip feature, zip the moodle-unclean.xml file only, download the zip file locally and unzip it. It is very important to download the xml file in zipped format to avoid unwanted character encoding when transferring from an operating system to another.<br />
<br />
* Move the downloaded Atlassian XML Cleaner Utility in the same folder where is your moodle-unclean.xml file.<br />
<br />
* Issue the following command from the command prompt: <br />
<br />
java -jar atlassian-xml-cleaner-0.1.jar moodle-unclean.xml > moodle.xml<br />
<br />
* If you launched the utility on your local computer, zip the just created (and hopefully cleaned) moodle.xml file and upload it in the same place from where you downloaded the moodle-unclean.xml file. Once uploaded, unzip it using the Moodle unzip feature.<br />
<br />
* Zip everything again (all the folder contents but the folder itself!).<br />
<br />
* Restore the course. It should work now.<br />
<br />
==What does "Some of your courses weren't saved!!" mean?==<br />
<br />
There are three possible causes of this problem:<br />
# Error - this happens when the backup procedure has found an error and so hasn't finished the backup of a particular course. These are "controlled" errors and the scheduled backup continues with the next course.<br />
# Unfinished - this happens when the backup procedure dies without knowing why. When the cron is next executed it detects that the last execution went wrong, and continues skipping the problematic course. A possible solution would be to raise the PHP/Apache limit in your installation (memory, time of execution...). By taking a look to your log tables you should be able to see if the "crash" is happening at exact time intervals (usually a problem with the max_execution_time php's variable), or if there is some exact point were all the courses are breaking (generally internal zip libraries, try to switch to external executables instead).<br />
# Skipped - this happens when a course is unavailable to students and has not been changed in the last month (31 days). This isn't an error situation - it's a feature, especially useful for sites with many unavailable old courses, saving process time.<br />
<br />
==How can I restore pre 1.6 non-ISO-8859-1 backups to Moodle 1.6 (Unicode)?==<br />
<br />
Any backup files with contents which are not 100% ISO-8859-1 will be a problem to restore to Moodle 1.6 (and upwards) running under Unicode. Instead, please try the following:<br />
<br />
# Make a clean install of Moodle 1.5.x (the latest version available)<br />
# Restore all your courses there (they should work if they were working originally)<br />
# Upgrade your site to Moodle 1.6 and run the UTF-8 migration script<br />
# Backup your courses again<br />
<br />
This will produce a new set of backup files that will be 100% UTF-8 and you will be able to use them with Moodle 1.6 without any problems.<br />
<br />
==Restoring a course results in broken HTML tags. What can I do?==<br />
<br />
This problem is due to a [http://bugs.php.net/bug.php?id=45996 PHP bug in libxml2 2.7.1] (the same bug reported with version 2.7.2 and 2.7.3). All HTML entities, such as &gt;, &lt; and &quot; are removed when a course is restored.<br />
<br />
To resolve the problem, you should use a different version of libxml2 such as 2.7.0 or 2.6.32 or compile PHP again libexpat instead of libxml2.<br />
<br />
At Gentoo servers, you can use<br />
<br />
echo ">dev-libs/libxml2-2.6.32" >> /etc/portage/package.mask<br />
<br />
See the discussion [http://moodle.org/mod/forum/discuss.php?d=111321 Restoring makes webpages and labels in code] for further information.<br />
<br />
==Why are some courses being skipped?==<br />
<br />
From 1.6 onwards, course backups automatically skip courses which are unavailable to students and have not been changed in the last month.<br />
<br />
==Why does restore stop, rather than completing?==<br />
<br />
Attempting to restore a course to an older version of Moodle than the one the course was backed up on can result in the restore process failing to complete. To ensure a successful restore, make sure that the version of Moodle you are restoring the course to is the same, or newer, than the one the course was backed up on.<br />
<br />
== See also ==<br />
<br />
*Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum]<br />
*[http://www.databasejournal.com/features/mysql/article.php/10897_3300511_2 databasejournal.com article on repairing database corruption in MySQL]<br />
<br />
Using Moodle forum discussions:<br />
*[http://moodle.org/mod/forum/discuss.php?d=66708 Scheduled backup fails] including possible solution to "An error occurred while copying files".<br />
*[http://moodle.org/mod/forum/discuss.php?d=99338 Restore stops]<br />
<br />
[[Category:FAQ]]<br />
[[Category:Backup]]<br />
<br />
[[es:FAQ Backup]]<br />
[[pl:Backup FAQ]]<br />
[[fr:FAQ de sauvegarde]]<br />
[[ja:バックアップFAQ]]<br />
[[pt:FAQ sobre cópias de segurança]]</div>Sylvaticus