How to find the automated backup of an accidentally deleted course

How to find the automated backup of an accidentally deleted course

by Rebecca O'Connell -
Number of replies: 0

When Moodle deletes a course it also deletes the database record containing the name of the file containing the automated backup. This is how you find that file.

  1. Find the deletion record in the log. You are looking for a "Delete" activity done by whatever user deleted the course.
  2. Note the date and time the deletion took place. 
  3. Go to [your file path]/moodledata/trashdir/. List the files and their dates modified (ls -laht in Linux/Unix).
  4. The folder containing your backup will have the a date modified that matches the deletion time from the log.
  5. cd into that folder. cd into whatever folder is in that folder (it will have a two character name, it doesn't matter what it is).
  6. Inside that folder should be a file with a sixteen character file name. Copy that file out of trashdir. Rename it [somename].zip
  7. Unzip [somename].zip (the command is "unzip [somename].zip")
  8. unzip acoursebackup.zip
  9. Quoting from recovery of accidentally deleted courses (v.2.2.6):
    If you see files/folders like:

    course     gradebook.xml      moodle_backup.xml  roles.xml   users.xml
    activities         files      groups.xml         outcomes.xml       scales.xml
    completion.xml     files.xml  moodle_backup.log  questions.xml      sections

    It's a backup! ;)

    To see the course name:

    head -n 4 moodle_backup.xml

    will show:

    <?xml version="1.0" encoding="UTF-8"?>
    <moodle_backup>
      <information>
        <name>backup-moodle2-course-testmobile-20121003-0812.mbz</name>
  10. Your zipped file is your backup, possibly suitable for restoring. I had to download the zip file in order to use it for restoring, and my FTP program insisted on downloading the unzipped folder instead of the zipped file. To create a restorable ZIP file, I had to compress (zip) the files, NOT the folder containing the files.
Average of ratings: Useful (2)