## General help

### Trying to recover files from automated backup .mbz file

Trying to recover files from automated backup .mbz file

I have an automated backup of a class in Moodle 1.9.  The size is 83 mb.  I have tried repeatedly to restore this class using the information from these forums to no avail.  Now, I would simply like to extract this file on my computer to recover some important files from it.  Is there a way to extract .mbz files? I've already tried on a Macbook pro at I am receiving error message, "unable to expand course-20110904-0000.mbz into desktop. No such file or directory".

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

The .mbz indicates the backup is from a 2.x version of Moodle.

Rename the filename extension of course-20110904-0000.mbz to

course-20110904-0000.zip.

Then copy the .zip to a 'test' folder (any folder name will do).  Unzip it in that folder - not the Desktop.

You'll see something like this in the 'test' directory:

activities                                 files          moodle_backup.log  roles.xml
backup-moodle2-course-9-20110925-1644.zip  files.xml      moodle_backup.xml  scales.xml
course                                     groups.xml     questions.xml      users.xml

the files folder contains the hashed folders as they existed in your data folder on the server

[root@moodle files]# ls
04  07  17  21  33  4a  68  7c  7d  82  8f  91  94  9e  a1  a3  b0  b2  b3  b9  f4

You'll have to open the file.xml file and look for tags like such:

<filename>sandcastle2.png</filename>

Then decript the contenthash found in the same .xml file:

Change directories files -> 33

You'll find:

-rw-r--r-- 1 root root 28154 Sep 25 16:44 3304a6c1ada2ce6d3c023bd8865b0609e200a41e

'sandcastle2.png' (that was it's name as referenced in the files.xml file).

'spirit of sharing',

Ken

Average of ratings:Useful (2)
Re: Trying to recover files from automated backup .mbz file

Hi Ken,

thanks for this info on reading the mbz files.  I converted them to zip and was able to extract them.  The files.xml opened up in my Dreamweaver program and I am able to see the content hash.  However, I'm lost when you state to decript the hash.  I understand the term, but don't know how to actually do it.  Would you have time to expound on that step?

BTW, I'm simply wanting to get the text from each course, which was built from some Word docs, but the course content changed here and there once they were in the moodle, so I thought it would be easier to upload the course files and get the newest version of the course content (text) this way.  Our goal is to update the word docs so we have the course content (text) easily available for other uses down the road.

Looking forward to hearing from you.

Trish

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

How about a silent video that shows both ... original request about files (recovery) and the current request for info on content contained therein?  There is no audio.

http://moodle.tcea.org/exploring_mdl2_backups.swf

Shows 'Features Demo.mbz' as the original 2 backup, copied to 'Features Demo.zip', unzipped, then explored - looking at files first, then content contained in the course.

'spirit of sharing', Ken

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

I am trying to edit the backup files in the new Moodle 2.3.3+ version.

I have renamed the mbz extention to zip and opened the folder

I have opened moodle_backup.xml file and made my changes.

I have some courses that show like 1000 sections with nothing in them and I wanted to delete them because I am having problems restoring these courses.

I have copied the moodle_backup_xml and need to zip the files and zip them as a mbz format.

I tried compressing them as a zip file. then renaming the zip file to mbz but when I try to restore it, it get a message the file is not a moodle format .

Any ideas or suggestions on how to do this?

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

@Vicki

Certain .xml files must be at the root of the zipped file ... such that, when un-zipped, they are found.

So, if you created a 'test' directory and extracted the .mbz in there, edited, and that's where the .xml files reside, one must recreate the zip from the contents of the test directory ... not the test directory itself.

Above you show 'moodle_backup_xml' ... isn't that supposed to be 'moodle_backup.xml' - ie, a file not a folder?

'spirit of sharing', Ken

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

Ok.  I created a folder called 'test'.. copied the mbz file to that folder.

then I renamed the file from mbz to .zip

I then extracted the zip files to the test folder.

I then edited the moodle_backup_xml file within the folder.

Renamed the zip file to mbz and when I tried to restore, I receive a error that it is not the correct Moodle Format.

I think where I am stuck is how to take the zipped file and put it back in the mbz format.  Renaming it is not working.  Is there a program I need that will allow me to put in the correct mbz format?

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

Once again ... moodle_backup_xml indicates a folder.  What you edited was moodle_backup.xml (see the 'dot' and xml extension?)

Once you have edited the moodle_backup.xml file making sure you've not inadvertently edited in-correctly ... leaving a start xml tag or and end xml tag with no corresponding start/end, then we re-zip the extracted *contents* of the test directory.

**In the test directory**, issue:

zip -r abackup.zip *

Must use -r (recursive) or zip won't create all the folders/files contained in the test directory.

That will complain about 'abackup.zip'.  That's ok.  Let it! ;)

Then rename the abackup.zip to abackup.mbz

mv abackup.zip abackup.mbz

The name of the file doesn't make a diff to Moodle.  It just looks at the filename extension (.zip/.mbz).

Am unaware of any program that does this, but it would make a handy utility to run on a server!  A .mbz file is a zip by another extension and used only for Moodle.  It's like a .docx ... it's a zip too!

'spirit of sharing', Ken

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

Well, guess seeing is better than telling! ;)

Screen capture with Jing and it did timeout on recording, but it completed enough to get you by ... I hope.  It does show Mac, but Windows users should be able to adjust - ie, translate to Windows-ese.

If you are removing a link/activity to a file, one would also cross reference and edit other related .xml files that reference the file you removed.

I have done this and it does work.  It's not something I'd like to make a living at doing ... but we do what we must!

'spirit of sharing', Ken

Average of ratings:Useful (2)
Re: Trying to recover files from automated backup .mbz file

Hello Ken:

I am trying to restore a mbz file to the moodle 2.1.1 platform, but the system shos this error message: error/tmp_backup_directory_not_found

I assumed the copy file needed to be repiared, I have already tried two file repairing software programs, but it didn't work.

I also tried to rename the file extension to zip, but I didnt't get results.

I hope you can help me with this problem.

thanks

Average of ratings: -
Re: Trying to recover files from automated backup .mbz file

Hmmmm ... got this via Moodle IM also ... to which I replied ... but will also here in case am in-correct (then others can correct the advice):

Operating systems have a temp directory.  Moodle wants it's own.
Look in your data folder for moodle (moodledata?).  There should be a 'temp' folder
there.
Contained therein is usually a 'backup' folder which is used by Moodle during backup
and restore processes.  It's the location where moodle builds the xml files and folders for
a course to create backups (.mbz's) and/or restore courses from backups.

If they don't exist, something happened with the install.  You've not mentioned what
operating system, nor any other what might be important information, so the
following is for Linux:

cd /var/www/moodledata
ls

should see a 'temp' folder there.
If not make one: mkdir temp and set ownership/permissions for apache:
chown apache:apache temp -R

Also, the phpinfo resource from the Site Admin menu will show settings for php ...
which does include a temp setting.  That really doesn't need to be changed as Moodle looks
for it's temp folder first.

Again ... if the directory is not there, it could be an indication that your
installation failed or hickup'd for some reason.  You might discover other things.

BTW, when Moodle 2 sees a .zip file during a restore process it will warn it's not a
'valid' backup file and will attempt to convert it to an .mbz.  Rename your backup
files and use .mbz extensions if the backups were created with a Moodle 2.

Ken

Average of ratings: -