moodledata/trashdir

moodledata/trashdir

by Syed Ali -
Number of replies: 6

Moodle Version 3.1


What does trashdir contain in moodledata?

Is it safe to empty by deleting all content in trashdir folder?

I observed that moodledata partition is using full space. I want to know the reason.



Average of ratings: -
In reply to Syed Ali

Re: moodledata/trashdir

by Ken Task -
Picture of Particularly helpful Moodlers

Evidently, someone, (teacher/administrator) is making a lot of changes to courses and files linked in courses/site.

A file that is no longer linked anywhere in Moodle is moved from filedir to trashdir via task/cron job and remains there for 4 days (hard coded ... no admin option to set when/frequency - like 1 day) until the task (which is part of cron) to remove the files from trashdir kicks in.   How often is cron run?

IF you are having a space crunch ... ie out of room ... one can manually remove the contents of trashdir safely.   Advise, that until the dust settles, check often and remove manually if needed.

Use du to keep an eye on space ... if you have linux and logwatch installed, check the daily messages from logwatch as that contains a section in the daily report concerning space on the entire system/partitions.

'spirit of sharing', Ken


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

Re: moodledata/trashdir

by Syed Ali -

Our filedir size also jumped from 400 GB to 700 GB and now data partition is showing 100% usage of disk space.

In reply to Syed Ali

Re: moodledata/trashdir

by Ken Task -
Picture of Particularly helpful Moodlers

Then manually remove contents of trashdir.   You might have to login via ssh and continually monitor trashdir as well as moodledata/temp/backup/ as that directory is used to restore backups to courses.

That backup directory might have some failed restores taking up more room.    Safe to remove those directories/files manually as well.

Contact any admins of site to inquire about activity.

Is autobackups turned on?  Might want to turn that off if it is.

'spirit of sharing', Ken

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

Re: moodledata/trashdir

by Jerry Lau -

If you run your cron on a regular basis, it empties it... you probably have not executed cron.php for a long time, correct?

In reply to Ken Task

Re: moodledata/trashdir

by Syed Ali -

Cron Job is running.


trashdir has taken care.

Now when I ran following query.

select *, FROM_UNIXTIME(timecreated) from mdl_files
where filesize > 0
and filename = 'backup.mbz'
and FROM_UNIXTIME(timecreated)  > '2017-08-09 13:20:00'


It shows 107 records of filename backup.mbz and each backup file in giga bytes.

mime type is application/vnd.moodle.backup

component: tool_recyclebin

filearea: tool_recyclebin

In reply to Syed Ali

Re: moodledata/trashdir

by Ken Task -
Picture of Particularly helpful Moodlers

Check the default settings for course backups.   Think, by default, a backup file name would include the course ID and the course short-name as well as a date/time stamp in the filename itself. 

So the filename of a backup might look like:

backup-moodle2-course-1402-moodle_online_teaching_and_learning-20160725-1323.mbz

Think it would be rare to set the backup file name to backup.mbz but guess someone could.   In your query include 'contenthash'.   That's really the path/location of the backupfile if saved back into filedir.   If those 107 records have the same contenthash value it's a single file ... not 107 individual backup files.

Backups could be made as no user backups ... which means student work would not be included in the backups.    Heck, had one site that hadn't re-set a multimedia course in almost three years and it's backup reached 139Gig.   This to say, yes ... backups of courses can reach Gig range in a K12 Moodle easily and in a short time frame as well.

Don't understand the reason for the references to:

component: tool_recyclebin

filearea: tool_recyclebin

Is your space issue ... ie 0 bytes free ... resolved?

'spirit of sharing', Ken


Average of ratings: Useful (1)