Where are the H5P libraries located in Moodle?

Where are the H5P libraries located in Moodle?

by Narit B -
Number of replies: 4

I already created the courses and also used H5P activities in the courses but now I have some technical issues about Moodle system on NAS QNAP so now I can't access Moodle anymore. I'm in trouble now because I didn't backup them.  T^T

Where are the H5P libraries located in Moodle?

And can I copy them directly without access Moodle and restore to the other Moodle Server?


Thank you

Average of ratings: -
In reply to Narit B

Re: Where are the H5P libraries located in Moodle?

by Ken Task -
Picture of Particularly helpful Moodlers

Do still have access to the moodle data directory AND the database server that was serving the moodle?

Depending upon how you 'developed' H5P moodle content, you **might** be able to recover the .h5p files out of moodledata by finding the contenthash file name of the file and then locating that contenthash file in the sea of files in moodledata/filedir/.    Copy them out of moodledata/filedir/.    Then be able to upload them again to another Moodle.

You will have to have ssh/command line access to the NAS QNAP and the ability to copy files OFF the NAS to some other location.

'spriit of sharing', Ken


In reply to Ken Task

Re: Where are the H5P libraries located in Moodle?

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up with specific directions ...

If you have access to your DB for Moodle make this query on it:

select contenthash,filename from `mdl_files` where `filename` like "%.h5p%"
 
Renders something like this:

contenthash     filename
acf2519f87924ca028f686756e6957fc5e2b5243     example-1.h5p

To find the file:

ssh into server
cd /path/to/moodledata/filedir/
Using the content hash above.

cd ac/f2/
ls -l
should list a file (something like this):
-rw-rw-rw-. 1 apache apache 3850292 Feb 17 07:56 acf2519f87924ca028f686756e6957fc5e2b5243

Use file -b on that file (your NAS may not have that command):

[root@sos f2]# file -b acf2519f87924ca028f686756e6957fc5e2b5243
Zip archive data, at least v2.0 to extract

Says it's a zip - which is true ... do NOT unzip it.

Copy that file out to some other location and give the copy it's humanly recognizable name:
cp acf2519f87924ca028f686756e6957fc5e2b5243 /home/someotherdir/example-1.h5p

Download the /home/someotherdir/example-1.h5p file

And am sure I don't have to remind ... but .... next moodle, take the time to make site backups! smile

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Where are the H5P libraries located in Moodle?

by Ken Task -
Picture of Particularly helpful Moodlers

And a follow up to the follow up ...

*** another possible ***
IF the moodle code directory is still on your NAS .... AND IF the moodledata directory is still present AND you can query the DB server for the Moodle ...
IF you can do the first suggestion about how to find .h5p' files, then
there is a good chance you can backup the courses.

The mysqlquery - which you should also be able to do via PHPMyAdmin

select id,fullname,shortname from `mdl_course';

That will render something like the following .... the important bit of info
is the ID.

+----+---------------------------------------------------------+-----------+
| id | fullname                                                | shortname |
+----+---------------------------------------------------------+-----------+
|  1 | Moodle 34                                               | M34       |
|  2 | SA                                                      | SA        |
|  3 | test                                                    | test      |
|  4 | Moodle Sharing                                          | MSHARE    |
|  5 | Installing Moodle Solr SLinux 6 or CentOS 6 or CentOS 7 | SLCENTOS

Then, from an ssh/shell session, in the moodle code directory ... go to /path/to/oodlecode/admin/cli/ directory

cd /path/to/moodlecode/admin/cli/

** must execute the scripts in admin/cli/ as the scripts read config.php of the moodle code directory for other variables.

There is a backup.php file there and it will backup one course by the ID you give
the script and according to the preferences for backing up courses (which, you probably can't reach via Web browser now)

For the sake of example, lets say your H5P stuff was in course id 4 above.

So ... from admin/cli/

php backup.php --courseid=4 --destination=/some/manually/created/directory/located/on/NAS/

A real example:

[root@sos cli]# php backup.php --courseid=4 --destination=/home/backup/m34/
== Performing backup... ==
Writing /home/backup/m34/backup-moodle2-course-4-mshare-20180217-1455.mbz
Backup completed.


List it:

[root@sos cli]# ls -l /home/backup/m34/*.mbz
-rw-rw-rw-. 1 root root 6804331 Feb 17 14:55 /home/backup/m34/backup-moodle2-course-4-mshare-20180217-1455.mbz


I can now download the .mbz file and restore that caurse to another moodle.

NOTE: forget about trying to backup course ID 1 ... that's the front page.   Cannot restore a course to the front page of any Moodle.

'spirit of sharing', Ken

Average of ratings: Useful (2)
In reply to Ken Task

Re: Where are the H5P libraries located in Moodle?

by Narit B -

Hi Ken Task

Very big thank you for you responded and very details in the step. 

I will try to explore and learn more from that together with my IT guys because I'm not much the knowledge about PHPMyAdmin & command line for the NAS system.


Thank you very much once again.