Delete user - Delete user private backup area?

Delete user - Delete user private backup area?

by Leslie Foster -
Number of replies: 3

If I delete a user, will it delete all of the files in the user private backup area?

I am hoping the answer is yes as a user has many Gb of course backups but I get an error when trying to delete files in the private backup area and hence cannot delete them.  I have seen posts where you can delete files individually but that requires a full reconciliation and a manual deletion of items from data tables....and I prefer not to do that.

Am using Moodle 3.1



Average of ratings: -
In reply to Leslie Foster

Re: Delete user - Delete user private backup area?

by Ken Task -
Picture of Particularly helpful Moodlers

Surprised no one has attempted an answer ... so here goes ...

First, what sort of error do you get when you try to delete files in users private files?  Did you try turning on debugging to see what Moodle had to say?

Used to be that the admin (superuser) of moodle site was truly the highest deity ... but that changed.  So did you login as this user via 'login as' and attempt to deleted the extra backup files?

If one is having issues with deleting files supposedly belonging to a user, one might have issues actually deleting the user ... dunno that for sure ... no longer run a 3.1.

But, if one is really in a space crunch ... one could resort to removing files manually ... find the file in moodledata/filedir/X/X/contenthashname remove the row in mdl_files table, manually remove the file from moodledata.   Uhhhh ... have had to that to recoup space for an admin who set autobackups to keep all and filled up a TB data partition in fairly short order.   Not pretty ... took hours ... but finally had enough free space for 'wiggle room'.

'spirit of sharing', Ken


In reply to Ken Task

Re: Delete user - Delete user private backup area?

by Leslie Foster -

Ken

Sorry.....I do not understand how I get from a XXX.mbz file to something in the filedir?  The files in the filedir (that I have browsed) are not big files like the 300mb course backups.  Perhaps my sample was not big enough and I missed the big files?


Regards


Les


In reply to Leslie Foster

Re: Delete user - Delete user private backup area?

by Ken Task -
Picture of Particularly helpful Moodlers

Again ...

"First, what sort of error do you get when you try to delete files in users private files?  Did you try turning on debugging to see what Moodle had to say?"

Query DB mdl_files table:

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

That's all meta data. Could sort by filesize or userid

Outputs like:

filearea    userid    filename    filesize    contenthash
course    6    backup-moodle2-course-10-car_product_indoor-20151209-1131.mbz    10401336    285f25dbd50f8ec9f40b44db15e7c38349dfee1e
course    6    backup-moodle2-course-67-tdp_504-20181120-0557.mbz    332963437    0e1f2fe7995872845947effa69806fe3e28a741e

See the contenthash of first backup? 285f25dbd50f8ec9f40b44db15e7c38349dfee1e

cd /path/to/moodledata/filedir/

find ./ -name 285f25dbd50f8ec9f40b44db15e7c38349dfee1e
./28/5f/285f25dbd50f8ec9f40b44db15e7c38349dfee1e

[root@server filedir]# ls -l ./28/5f/285f25dbd50f8ec9f40b44db15e7c38349dfee1e
-rw-rw-rw- 1 apache apache 10401336 Dec  9  2015 ./28/5f/285f25dbd50f8ec9f40b44db15e7c38349dfee1e

10401336 is actual size of file

Meta data had same,

file -b ./28/5f/285f25dbd50f8ec9f40b44db15e7c38349dfee1e
gzip compressed data, from Unix

shows a gzip compressed ... it's a valid moodle backup .mbz file.

Add to your query the offending userid.

Did you login as the user?    Then check users private files area?  Have to pretend to restore but don't to see the users private file area.

'SoS', Ken