Backup for BIM 2.0

What follows is a journal of the attempt to bring BIM 2.0’s backup functionality into line with the new approach in Moodle 2.x.

Done. Appears to be all working. Will work on restore next and do some testing.


First up is trying to understand the developer docs on the new backup process. What follows is an attempt to both summarise/understand those docs and explain what changes I’ve made to BIM 2.0. The Backup 2.0 general architecture documents are also used.

What I believe it all boils down to is the ability to convert the database structure for a BIM activity into an XML file/structure. The aim here will be to keep the XML structure produced as close to that produced by 1.9 as possible.

Steps required

  1. Preparation – knowing what to backup
    Much of this is done in the “BIM data” section below.
    1. Draw the DB schema.
    2. Identify where the user information is located in the schema.
    3. Determine correct order of backup.
    4. Identify attributes and elements.
      All “id” fields should be attributes.
    5. Identify not needed elements.
      Any field except those in parent elements should be included.
    6. Identify the file areas used.
      Text fields and attachements appear to fit into this sector. This appears to be a bit new in Moodle 2.
    7. Annotating important bits
      e.g. the ID fields.
  2. Remove the old backup stuff.
    Basically backuplib.php in the bim directory.
  3. Tell Moodle that BIM 2.0 is supporting backups.
    Add the following to mod/bim/lib.php
    case FEATURE_BACKUP_MOODLE2:          return true;
  4. Set up the directory for the code
    create mod/bim/backup/moodle2
  5. Set up and test the backup process (which won’t work at the moment).
    The backup documentation includes a simple script that speeds up the develop/test cycle for backups. put that in place and run it. Breaks as expected
  6. Start putting in the code
    1. create empty mod/bim/backup/moodle2/backup_bim_settingslib.php
    2. backup_bim_stepslib.php – another empty file
    3. backup_bim_activity_task.class.php the place the above files are used. For now just some skeleton code with empty methods.
  7. Run the backup again.
    Which runs without error as expected.
  8. Create the bim.xml file – as an empty file
    • Some empty code into backup_bim_stepslib.php
    • Call the method from the steps file from backup_bim_activity_task.class.php.
  9. Now to define each of the elements essentially a translation of the provided code with the description of the bim data below. This produces an empty backup file for bim.
  10. Define the tree of data following the skeleton code.
  11. Connecting it all to the database
    A fairly simple set of method calls building on the above. Tested and all seems to be working. Woo hoo!
  12. Annotating IDs
    This appears to be related to signposting user (and other) information, something I missed the first time.
    For BIM, the relevant fields to annotate are user and group.
  13. Annotating files
    Not sure about this section. Need to read some more and update.
  14. Encode references to URLs?
    Done as per example.

BIM Data

The following is based on this 2010 post documenting the development work on the backup process for BIM 1.0. With some extra work based on the preparation information from above.

The bim data hierarchy (bullet points represent table names)

  • bim
    id (attr)
    course (not needed) **** CHECK IF THIS IS INCLUDED ****
    intro (????file area???)

    • bim_group_allocation
      id (attr)
      bim (not needed)
    • bim_questions
      id (attr)
      BIM (not needed)
      title (???? file area ???? )
      body (??? file area????)
    • bim_student_feeds
      id (attr)
      bim (not needed)
    • bim_marking
      id (attr)
      bim (not needed)
      question (this is an id back into bim_questions)
      link (???file area??)
      title (??file area??)
      post (?? file area?? )
      comments (?? file area??)

In BIM 1.0 the user data includes: student feeds, marking and group allocation.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s