Moodle 3.6- Deleting from /data/moodledata/filedir without Moosh

Moodle 3.6- Deleting from /data/moodledata/filedir without Moosh

by Aarthi Ramesh -
Number of replies: 1

Hi!

I am the admin/instructor for my team's corporate Moodle 3.6v instance. 

I was warned of a very high server volume usage by the team's DBA and on investigation using the CLI, I found that the .mbz backups being stored in /data/moodledata/filedir dated back to Oct 2020 on a weekly basis. I adjusted the cron and tasks using the GUI, so nothing over 5 backups is saved. When I checked back using the CLI, the updated cron task has run successfully, but the older backups still exist.




I tried installing and running Moosh and after unsuccessful attempts to deploy, figured that due to a php version incompatibility, 

I have to find a manual way to delete these .mbz files from filedir and associated links without causing the entire prod. environment to come down. Please advise.

Other observation to share-

I cannot see these old backup files under the respective courses using the GUI.

Under the courses where I did see backups that I did not require, I deleted them. When they showed up in trashdir, I deleted them manually using the CLI.

Thanks!

Aarthi

Average of ratings: -
In reply to Aarthi Ramesh

Re: Moodle 3.6- Deleting from /data/moodledata/filedir without Moosh

by Ken Task -
Picture of Particularly helpful Moodlers

Don't run a 3.6 anymore but automated backups when choosing 'Specified Directory ..." should have a config box below that for giving the full path to the specified directory.   Usually that's outside moodledata/ and not in moodledata/filedir/ (sea of files by moodle file system).

Check box on for 'choose specified directory' ... does that open that other box for setting full path to designated directory in 3.6?

IF autobackups had been set up prior to changing above settings then backups when to moodledata/filedir/ sea of files ... also if a teacher runs a backup those could be stored in teachers private files area and even an admin level user won't see those.    So you need a DB query of mdl_files for .mbz files to see the info related to any/all .mbz files (which might also include recyclebin files).

select contenthash,filename,filesize from mdl_files where filename like '%.mbz

That will display something like:

contenthash    filename    filesize
7076296142de12818f4b55e692dbb8a32452b319    backup-moodle2-course-136-mdlsampler-20190910-0027.mbz    40937386
30233431ac719d20989f871a3fd3a5ae30a4c752    backup-moodle2-course-3-mdlsampler-20200113-1148.mbz    68007357
7076296142de12818f4b55e692dbb8a32452b319    backup-moodle2-course-136-mdlsampler-20190910-0027.mbz    40937386
da39a3ee5e6b4b0d3255bfef95601890afd80709    backup-moodle2-course-3-mdlsampler-20191201-1708.mbz    61897704
c32682b46d7b24ea3814dfc9065738187243aaf5    backup-moodle2-course-57-ktnoclas-20200611-1200-nu.mbz    8832
1c2b7ff4bd3b4b59ec0bad8264486673bbb29ebe    backup-moodle2-course-56-mshare38-20200615-1336-nu.mbz    25970808
7f0e8be5d1fdd8718eeda2d4147bb2b6529c599d    backup-moodle2-course-59-mdlcli-20200622-0801-nu.mbz    16875
c935ec828d1312e40503a34482c0b99cca613c52    backup-moodle2-course-57-ktnoclas-20200920-2018-nu.mbz    7896

contenthash column does show location in sea of files /moodledata/filedir/

from command line: cd /path/to/moodledata/filedir/

[root@sos filedir]# find ./ -name 1c2b7ff4bd3b4b59ec0bad8264486673bbb29ebe
./1c/2b/1c2b7ff4bd3b4b59ec0bad8264486673bbb29ebe

show path to file ./1c/2b/ and if you notice the filename is the contenthash value.

Check if a backup file:

[root@sos filedir]# file -b ./1c/2b/1c2b7ff4bd3b4b59ec0bad8264486673bbb29ebe
gzip compressed data, from Unix

Gzip compressed would be correct or a .mbz file.

Removing this way involves above to find.  rm command (very carefully) for the physical file, then removal of the row in mdl_files table.

That manual process should probably used *only* if one has a backup of the DB and minimal backup of moodledata/filedir/.

Best to set options for autobackups and run it to see if keeping number required, etc..

What was the problem with moosh? specifically ... command not found or the warning about running as root or ???

'SoS', Ken