Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Restore API: Difference between revisions

From MoodleDocs
(Adding backup category)
Line 27: Line 27:


[[Category:API]]
[[Category:API]]
[[Category:Backup]]

Revision as of 09:35, 13 March 2015

Moodle 2.0

The Restore API provides a way to restore your plugin's data from a backup file created in Moodle 2.0 or later. For the information on how backup files are created, see Backup API. For the information on how to support restoring data from backup files created in Moodle 1.x, see Backup conversion API.

Overview

This page provides just a quick reference to the restore machinery in Moodle 2.0 and higher. There is a detailed documentation available at Backup 2.0 page - see especially the tutorial for plugin authors at Restore 2.0 for developers page.

Moodle restores data from course backups by executing so called restore plan. The restore plan consists of a set of restore tasks and finally each restore task consists of one or more restore steps. You as the developer of a plugin will have to implement one restore task that deals with your plugin data. Most plugins have their restore tasks consisting of a single restore step - the one that parses the plugin XML file and puts the data into its tables.

API for activity modules

Files

The files that implement the restore support in your activity module must be located in the subdirectory backup/moodle2/ in your plugin's folder (yes, it's the same folder where the backup related files are located). So, if you are developing the activity module called foobar then the restore files will be located in mod/foobar/backup/moodle2/ folder.

The following two files are supposed to exist in that location (replace foobar with the name of your module):

restore_foobar_activity_task.class.php
Provides the activity task class
restore_foobar_stepslib.php
Provides all the restore steps classes

(to be continued)


See also