Note:

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

Backup: Difference between revisions

From MoodleDocs
Line 25: Line 25:
==See also==
==See also==


*[[Backup 2.0 for developers]]
*[[Backup and restore FAQ]]
*[[Backup and restore FAQ]]
*Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum]
*Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum]

Revision as of 11:54, 2 December 2010

Please add backup and restore documentation for new developers here...

Back Up for your Module

Your backup functions should sit in a file called backuplib.php in your module folder. As a minimum you should write the following functions:

  • MODULENAME_backup_mods($bf,$preferences) - backs up all instances of your module
  • MODULENAME_backup_one_mod($bf,$preferences,$scefcentre) - backs up a single instance of your module
  • MODULENAME_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) - generates an array of course and user data information used to select which instances to backup (and whether to include user data or not). This includes details at [0][0] and [0][1] about the course module name and number of instances for the course and at [1][0] and [1][1] with the module name and count of user information.
  • MODULENAME_check_backup_mods_instances($instance,$backup_unique_code) - generates an array of course and user data information for a specific instance.
  • MODULENAME__encode_content_links ($content,$preferences) - recode links to ensure they work when reimported.

MODULENAME_backup_one_mod should generate XML output by calling the fwrite() function. This XML should cover all fields in the database:

//Start mod fwrite ($bf,start_tag("MOD",3,true));

//generate XML representing the DB fwrite ($bf,full_tag("ID",4,false, 'VALUE_GOES_HERE')); fwrite ($bf,full_tag("TEXT",4,false, 'VALUE_GOES_HERE'));

//End mod $status =fwrite ($bf,end_tag("MOD",3,true));

See also

Using Moodle forum discussions: