Recovering a Historic Course

Recovering a Historic Course

by Patrick Rynhart -
Number of replies: 9

We've got a very large Moodle installation - our Site Data folder is ~15 Terabytes.  Recently we had to recover a Course that had been deleted approximately a year ago.  We did have everything backed up via Commvault, but it took us Months to get everything back via lots of Tapes (i.e. the site data restored to a temporary location).

So Question: Given a historic database and a course, is it possible to determine which subdirectories in a sitedata folder are needed ?  (As opposed to restoring everything.). If so - how do you go about doing this ?

Average of ratings: -
In reply to Patrick Rynhart

Re: Recovering a Historic Course

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
I don't have a good answer except to say that you are save to delete cache, localcache, temp and sessions folders. But the majority of your data will be in the course folder structure and there is no way I know of to really sort through those easily. You can search for files over a certain size and if you have been doing a lot of course backups, you could probably clear out a lot of .mbz files.
I do recommend however, using the automated course backup to store a copy of courses in a remote location. That way you have a quick and easy to restore a course should need be. I set mine to just keep one copy and only back up courses that have changed. I then have a single folder with all courses that I can refer to when needed.
In reply to Patrick Rynhart

Re: Recovering a Historic Course

by Ken Task -
Picture of Particularly helpful Moodlers

Maybe am not following ... but, question ...

Can you backup that course via command line script in admin/cli/backup.php and save it out into another directory outside of moodledata.

If so, one can extract the files.xml and the files directory to get the contenthash value in the files.xml which shows the location of the  file in sea of files in moodledata.

Something like that @ https://sos.sosoftexas.org/scripts/clipoof.txt

'SoS', Ken

In reply to Ken Task

Re: Recovering a Historic Course

by Patrick Rynhart -

We're wanting a generic way to be able to determine which files/folders (from sitedata) are going to be needed if we end up needing to recover a course in the future.  We don't know which courses are going to end up needing to be recovered in advance.

Example: 1 year ago a lecturer deletes a course and leaves the organisation.  A year later a new lecturer arrives and wants to see what the Moodle course was like a year ago.  We have DB and Sitedata from a year ago, but Sitedata is massive (and takes 3 months to recover from tape).  If we could recover just the part of sitedata that is needed then it would be much, much faster.  So my question is, given an old DB (and a course) how do you getting a complete list of what's needed from the Sitedata folder ?

In reply to Patrick Rynhart

Re: Recovering a Historic Course

by Patrick Rynhart -
Ah @Ken Task - I kind of follow. But it seems that we would need to have a full sitedata beforehand for this approach to work mixed
In reply to Patrick Rynhart

Re: Recovering a Historic Course

by Ken Task -
Picture of Particularly helpful Moodlers

Ok, think I'm understanding ...

Maybe should be making no user backups of all courses - scripted - breaking up the creation of those backups by course ID's - like 2-50, next run 51-100, etc.

If ya had those, one could restore or extract ...

https://sos.sosoftexas.org/scripts/extract/
See the video in above directory.

Kinda the same thing Daniel has described - minus the DB query to find the contenthash and finding those files in massive sea of moodledata/filedir/

Could adapt extract to apply - maybe.

'SoS', Ken

In reply to Ken Task

Re: Recovering a Historic Course

by Patrick Rynhart -
Great - thank you very much for the replies and ideas. Much appreciated.
In reply to Patrick Rynhart

Re: Recovering a Historic Course

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

This can be done in principle, but is probably only worthwhile if you are looking for a very small number of files. The files are not organized in the data directory by courses, but they are assigned a location base on a hash of the content.

If you have the database restored and access the course and need a file belongs in the course. you need to find the context id where it is used and know the file name associated with it there. You would use those to locate the the reference in the files table. There should be a contenthash field stored in that record that is the file name that the file is stored under in data directory. The subdirectory it is stored in is determined by the first for characters of the content hash. You should read through the Files API dev docs to make sure this makes sense before trying it.

In reply to Daniel Thies

Re: Recovering a Historic Course

by Patrick Rynhart -

Great - thank you for the reply.  This gives us some ideas.  Thank you