Respaldo y restauración FAQ

De MoodleDocs

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Esta página necesita actualizarse con la información existente en la documentación vigente/moderna/actualizada en el idioma inglés original para Moodle. Se le sugiere al lector que consulte la página original en idioma inglés cuyo enlace está al fondo de esta página. y que, por favor, actualice esta información y quite la plantilla {{Actualizar}} cuando haya terminado.     (otras páginas pendientes de actualizar)


¿Cómo respaldo un curso?

Vea Respaldo del curso y Respaldo de curso automatizado.

¿Cómo restauro un curso?

Vea Restaurar un curso.

¿Cómo respaldo mi sitio?

Vea Respaldo del sitio.

¿Cuales son los pros y los contras de respaldos de cursos contra respaldos del sitio?

Los Respaldos del sitio están recomendados para tener todos los datos guardados con la mejor confianza y el mínimo tiempo para recuperación.

Para un administrador del sitio, los Respaldos de curso automatizados son más costosos en términos de tiempo, uso de CPU y espacio de almacenamiento. El tiempo para recuperación para tener un sitio corriendo de nuevo toma más que un Respaldo del sitio. Sin embargo, los profesores y administradores podrían encontrar que los respaldos de curso son una manera de crear una copia "fresca" de un curso, que puede ser re-utilizada (en veriones antiguas de Moodle; para versiones recientes vea Importar datos de curso), o como un método para distribuir un curso (o varios) a otros sitios Moodle.

¿Porqué es mi Respaldo de curso automatizado mucho más pequeño en tamaño que mi respaldo manual del curso?

Esta es una decisión intencional de diseño. Debido a la forma en la que los archivos son almacenados en Moodle 2.x y 3.x, no hay necesidad de incluir los archivos en el respaldo si Usted está planeando restaurarlos en el mismo sitio Moodle. El dejarlos fuera ahorra un enorme espacio de disco y hace el procedimiento del respaldo mucho más rápido.

¿Cuales datos no están contenido dentro de los respaldos de curso?

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:

  • Quiz questions are only backed up if at least one question from their category has been added to a quiz.
  • Scales are only backed up if they are used by at least one activity.
  • Users' passwords are not backed up when the "Include enrolled users" option is selected.
  • Glossary data
  • Badges - if they have not been awarded to at least one user and users are not included in the course backup.

¿Cómo puedo respaldar o restaurar un curso muy grande?

Vea Respaldo via CLI en Respaldo del curso y Restauración via CLI en Restaurar un curso (nuevo a partir de 3.10 en adelante).

El proceso termina con: "Error: An error occurred deleting old backup data". ¿Qué debo hacer?

This part of the backup (or restore) procedure tries to delete old info, used in previous executions, performing the following tasks:

  1. Delete old records from "backup_ids" table: Check the table exists, repair it and try again.
  2. Delete old records from "backup_files" table: Check the table exists, repair it and try again.
  3. Delete old files from "moodledata/temp/backup": Delete the dir completely and try again.
Backup error message

For points 1 & 2, there are various ways of repairing tables, including using MySQL Admin.

For point 3 see below:

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.

El proceso termina con: "XML error: not well-formed (invalid token) at line YYYY". ¿Qué puedo hacer?

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...).

The best method to handle this issue is:

  • Unzip the problematic backup file under one empty folder.
  • Open the moodle.xml with Firefox. It will show you where (exact char) the problem is happening.
  • Edit the moodle.xml file with some UTF8-compatible editor and delete such characters. Save changes.
  • Test the moodle.xml file again with Firefox until no error was displayed.
  • Zip everything again (all the folder contents but not the folder itself!).
  • Restore the course. It should work now.
  • Restore still not working? See the next question.

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.

El proceso termina con: "moodle xml not found at root level of zip file". ¿Qué puedo hacer?

If you are restoring from a zip file backup make sure the moodle.xml file is at the root level. To ensure this:

  1. Unzip the backup file of the course (example: mycourse.zip)
  2. Once the file is unzipped, open the folder (example: mycourse).
  3. Select the folders within the mycourse folder AND the moodle.xml file and create a zip of those item (example: mycourse_new.zip)
  4. Upload the new zip file (example: mycourse_new.zip) and restore from that.

If the backup file is guaranteed to be correct, check paths to external files (zip, unzip). Incorrect settings also lead to this error message (see the Using Moodle forum discussion moodle.xml not found in root... and MDL-14812).

El proceso termina con: "An error occurred while copying the zip file..."

This problem is most likely caused by a permissions issue in the destination directory. Backup files are copied to "XXX/backupdata" under your dataroot directory (where XXX is the id of the course being backed up).

The problem could also be caused by a disk being full, though this is far less likely.

To obtain precise information about what's happening, you can enable debug messages in Administration > Server > Depuración (select the maximum level - DEVELOPER) and/or check the web server error logs.

Sigo teniendo un error XML error. ¿Cómo puedo limpiar el archivo XML cucho?

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:

  • 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.
  • Rename the unclean moodle.xml file to moodle-unclean.xml.
  • 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.
  • Move the downloaded Atlassian XML Cleaner Utility in the same folder where is your moodle-unclean.xml file.
  • Issue the following command from the command prompt:
java -jar atlassian-xml-cleaner-0.1.jar moodle-unclean.xml > moodle.xml
  • 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.
  • Zip everything again (all the folder contents but the folder itself!).
  • Restore the course. It should work now.

¿Qué significa "¡¡Algunos de sus cursos no fueron guardados!!" ?

There are three possible causes of this problem:

  1. 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.
  2. 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.
  3. 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.

¿Porqué son saltados algunos cursos?

AutoBackup skip settings

Moodle's Course backups routines are instructed to automatically skip courses based on three settings in Administration > Site administration > Courses > Backups > Automated backup setup. The Moodle administrator(s) use those settings to specify whether to Skip hidden courses (set by default to 'Yes'), Skip courses not modified since (set by default to '30 days'), and Skip courses not modified since previous backup (set by default to 'No'). A course which meets any of the enabled criteria will be skipped during the next run of Course backups.

¿Porqué se detiene la restauración, en lugar de completarse?

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.

If it stop unexpectedly with no errors shown try again with Depuración switched on. Any errors you now see can help experts in the support forums diagnose your problem. You can also check the discussion links in the See also section below for further advice.

La restauración se detiene con el mensaje "Trying to restore user xxxx from backup file will cause conflict"

This message is displayed when:

  1. The target site has a user xxxx (xxxx being the username) - often the admin user
  2. The backup archive being restored also contains a user xxxx (same username)
  3. After various comparisons, Moodle has determined that the target site user xxxx and the backup user xxxx aren't the same person, for example: if these users have different email addresses.

If 1, 2 and 3 are all true, the restore process stops in order to prevent the backup user xxxx's activities (forum posts, quiz attempts, assignment uploads, etc) from being associated with the target site user xxxx.

Here are the possible methods to make the xxxx users match (and resolve the conflict):

a) Modify the backup archive users.xml file and make the email or firstaccess fields match the ones in target site. Note that the moodle-filename-backup.mbz is a zip file and can be renamed to moodle-filename-backup.zip and unzipped. When editing is complete, re-zip and then rename using the original file name with the "*.mbz" extension.

b) Modify the target site and set the user email or firstaccess fields to match the ones in backup archive users.xml file.

c) In Moodle 3.0.3 onwards and for admin user conflicts only, enable the setting 'Allow admin conflict resolution' in Site admin > Courses > Backups > General import defaults. This will result in the username in the backup file being renamed to 'admin_xyz'.

¿Porqué están rotos algunos enlaces del curso en un curso restaurado?

Inter-activity links must be absolute (full) URLs e.g. http://site.com/mod/resource/view.php?id=xxx in order to be processed properly during backup and restore.

Any relative URLs e.g. /mod/resource/view.php?id=xxx, ../resource/view.php?id=xxx or view.php?id=xxx will result in broken links when the course is restored.

Restaurar un curso resulta en marcas (tags) HTML rotas. ¿Qué puedo hacer?

Se sabe que esto es causado por versiones antiguas de libxml2 y PHP - intente actualizarlas a las versiones más recientes.


¿Cómo puedo extraer archivos originales de un archivo de respaldo Moodle?

If you really want to get original files from the backup file (an ".mbz" file) you downloaded (using the backup and restore feature), you can do so in much the same way as is suggested above.

The backup file can actually be opened with any zip/unzip program you can download. Once you open the file, you need to extract:

   The files.xml file.
   The files directory (folder).

Next step would be to open the "files.xml" file in a text editor, and:

   Search for the name of each file you want to get.
   Take note of the value of the corresponding contenthash tag.
   In the "files" folder you extracted, locate the file whose name is the same as the value of the contenthash and which will always be located in a folder whose name corresponds to the two first characters of the file name.

For example, let's assume there is a "backup_courses-120730.mbz" file of which the "files.xml" file and the "files" folder have been extracted. There is a PDF file named "Leadership.pdf" that is required for another purpose.

Open the files.xml file and:

1. Search for the string "Leadership.pdf", which in this case is found under the following <file id...> group tag:

 <file id="12345">
 <contenthash>fb6cf43a9b2d432403c70a2cb4c340dbb6225631</contenthash>
               :
 <filename>Leadership.pdf</filename>
               :
 <license>allrightsreserved</license>
 <sortorder>1</sortorder>
 </file>

2. Take note of the corresponding contenthash value: fb6cf43a9b2d432403c70a2cb4c340dbb6225631.

3. As the first two characters of the contenthash are "fb", open the "fb" folder inside the "files" directory (which was previously extracted), and there is a file named "fb6cf43a9b...". Rename that file as "Leadership.pdf", and then move it to another location. Repeat this for all the files required, using the correct contenthash value of course.

¿Qué pasa si restauro un respaldo que contiene una tarea de Moodle 2.2 y más antiguos?

The assignment activity module was completely rewritten in Moodle 2.3. Thus, assignments from Moodle 2.2 and older (e.g. from Moodle 1.9) need to be upgraded in order to continue being usable. See the section 'Restoring course backups from Moodle 2.2 and older' in Herramienta para actualización de tarea for details of what to do.

Error MySQL dmlwriteexception al restaurar un curso

If you obtain a dmlwriteexception error when restoring a course, it is recommended that InnoDB tables are converted to the Barracuda file format. See the section 'Converting InnoDB tables to Barracuda' in Administración por línea de comando for details of why this is recommended plus information on a tool for converting tables.

Documentación muy antigua, probablemente obsoleta

Tengo un curso muy grande, mayor de 2GB, y el proceso de respaldo se detiene.

Los cursos mayores de 4GB no pueden restaurarse a menos que se active una opción experimental. Vea debajo el 'Nuevo formato de respaldo'.

Below that size, large courses can be restored in Moodle, but sometimes it needs a bit of tweaking to get it right. Moodle backup files are *.mbz fies and can be renamed to zip files. They can be unzipped, then edited, rezipped and restored. It does not matter if you are using a Linux or Windows or Mac server, a local host or anything else, the technique is the same.

The editing comes in two different ways, one is the resources, activities, quizzes, images. video files and so on are listed, written and referred to in the moodle.xml file. You can find the starting point and the end point of each resouce that you can delete out of the xml file.

The xml might look something like this:

 <file id="111">    <contenthash>b11ac9bc0cebee17acfd28d13b548331f76645bc</contenthash>
   <contextid>21</contextid>
   <component>mod_resource</component>
   <filearea>content</filearea>
   <itemid>0</itemid>
   <filepath>/</filepath>
   <filename>howtomakeatimemachine.flv</filename>
   <userid>4</userid>
   <filesize>1092320586557</filesize>
   <mimetype>video/flv</mimetype>
   <status>0</status>
   <timecreated>12345432123</timecreated>
   <timemodified>12345432123</timemodified>
howtomakeatimemachine.flv
   <author>Fred Nurks</author>
   <license>allrightsreserved</license>
   <sortorder>0</sortorder>
   <repositorytype>$@NULL@$</repositorytype>
   <repositoryid>$@NULL@$</repositoryid>
   <reference>$@NULL@$</reference>
 </file>

When editing, make sure all this is deleted, everything between the <file></file> tags.

The second part of editing is locating the actual resouce if it is an image, a separate file or video then deleting it. Really large mbz files tend to have a lot of videos, often flv files, or uncompressed images, like tiffs. They can be found, and deleted easily, in the directory tree of the backup.

You can then rezip the edited file, rename it to an mbz and, if you have edited it right, it should restore. You can use the original file to break down really large backups over and over into four or five smaller mbz files, as many as you like.

It is recommended that you test the technique first on a smaller file, it is easier to follow and gets you used to xml structuring and so on. Say one course with a couple of pages, a number of different image types, a couple of videos will help you immensely.

You do not have to worry about permissions in Windows or Xos servers, or concern yourself with editing rights usually. However, you may be required to ensure you are the owner fo the files being edited.

 NOTE: Before re-zipping, check to make sure you have removed all references to the pages/files/resources you have deleted in the moodle-backup.xml file as well. here msay be none, but check anyway.

Uso del nuevo formato de respaldo (experimental)

If you have large courses you may find it useful to turn on an experimental option introduced in Moodle 2.6, 'Enable new backup format' (on the admin menu under Development/Experimental/Experimental settings).

This option selects a different internal backup format. Without this option, you cannot back up courses larger than 4GB.

You can change this option at any time. Whatever the option is set to, restore works for both the old and new format. The option only affects newly-created backups.

When you use this option, backup files still have the .mbz extension and work the same way, but there are some differences:

  • There is no limit on total backup size. (We have tested with courses up to about 10GB.)
  • Files may be slightly smaller.
  • If you need to edit this type of backup file manually, you will need to rename the .mbz file to .tar.gz, instead of .zip. You may need to use different software to extract and recompress this type of file. We have tested using GNU tar on Windows and Linux.

The new backup format is experimental, but is being used in some large sites and may be enabled as default in a future Moodle version. If you find problems with it, please report them in the Moodle tracker.

¿Cómo puedo extraer archivos originales del archivo de un archivo de respaldo de Moodle?

If you really want to get original files from the backup file (an ".mbz" file) you downloaded (using the backup and restore feature), you can do so in much the same way as is suggested above.

The backup file can actually be opened with any zip/unzip program you can download. Once you open the file, you need to extract:

   The files.xml file.
   The files directory (folder).

Next step would be to open the "files.xml" file in a text editor, and:

   Search for the name of each file you want to get.
   Take note of the value of the corresponding contenthash tag.
   In the "files" folder you extracted, locate the file whose name is the same as the value of the contenthash and which will always be located in a folder whose name corresponds to the two first characters of the file name.

For example, let's assume there is a "backup_courses-120730.mbz" file of which the "files.xml" file and the "files" folder have been extracted. There is a PDF file named "Leadership.pdf" that is required for another purpose.

Open the files.xml file and:

1. Search for the string "Leadership.pdf", which in this case is found under the following <file id...> group tag:

 <file id="12345">
 <contenthash>fb6cf43a9b2d432403c70a2cb4c340dbb6225631</contenthash>
               :
 <filename>Leadership.pdf</filename>
               :
 <license>allrightsreserved</license>
 <sortorder>1</sortorder>
 </file>

2. Take note of the corresponding contenthash value: fb6cf43a9b2d432403c70a2cb4c340dbb6225631.

3. As the first two characters of the contenthash are "fb", open the "fb" folder inside the "files" directory (which was previously extracted), and there is a file named "fb6cf43a9b...". Rename that file as "Leadership.pdf", and then move it to another location. Repeat this for all the files required, using the correct contenthash value of course.

What is the default format used in Moodle backup files?

The default format in Moodle backups is TGZ. If you make a backup, and examine the file with an HEX file viewer, you can see that the file starts with #1F8B (gzip file marker).

But, if you add the following line to your config.php file:

$CFG->usezipbackups = true;

and examine the file with an HEX file viewer, you will see that the file starts with #504B0304 (zip file marker)

Vea también

Using Moodle forum discussions: