Thousands of backups in the recycle bin even without automated backups

Thousands of backups in the recycle bin even without automated backups

by Eric Phetteplace -
Number of replies: 4

We appear to have over 2,500 .mbz backup files in our recycle bin despite not having automated backups on, so I have no idea how we accumulated so many. For context, we run about 800 courses a semester, the instance was created fresh this summer, we only have a little over a thousand courses total. So somehow all (or most) of our courses are being backed up a few times a week into the bin. It's a massive burden on our file storage system, nor do we have any idea how to even access and use all these backups stored in the recycle bin even if we wanted to, so I'd love to prevent this from happening.

Here's the ad hoc report I used to discover this:

SELECT id, filename,
CONCAT(CEILING(filesize / 1048576.0), 'mb') as size,
component, filearea,
FROM_UNIXTIME(timecreated, '%Y %D %M %h:%i:%s') as time_created,
FROM_UNIXTIME(timemodified, '%Y %D %M %h:%i:%s') as time_updated
FROM {files} f
WHERE filename LIKE '%.mbz'
AND (component = "tool_recyclebin"
OR filearea = "recyclebin_course")
ORDER BY filesize DESC
And here are some sample result rows:
idfilenamesizecomponentfileareatime createdtime updated1backup.mbz2597mbtool_recyclebinrecyclebin_course2020 2nd September 03:20:592020 2nd September 03:25:172backup.mbz2597mbtool_recyclebinrecyclebin_course2020 2nd September 03:25:522020 2nd September 03:28:053backup.mbz863mbtool_recyclebinrecyclebin_course2020 1st September 05:20:512020 1st September 05:21:134backup.mbz862mbtool_recyclebinrecyclebin_course2020 1st September 05:35:092020 1st September 05:35:33

Average of ratings: Useful (1)
In reply to Eric Phetteplace

Re: Thousands of backups in the recycle bin even without automated backups

by Ken Task -
Picture of Particularly helpful Moodlers
Moodle version?

If you add userid to your query is result showing same user id or different user id's?

To the best of my knowledge, there is no automated task in a stock code moodle to delete modules/resources from courses.   Deletion of modules/resources from a course is the only process that would create recyclebin files in the sea of files in moodledata/filedir/

In the set up of recyclebin:
admin/settings.php?section=tool_recyclebin

What are settings ... the times?

To be able to manually delete recyclebin files in settings turn 'Auto Hide' OFF ... un-check
Then go to one of those courses you see in your report as having recyclebin files ... should see a recyclebin link in course admin menu.   Gives you ability to manually delete them.

In scheduled task ... check settings for
\tool_recyclebin\task\cleanup_course_bin
\tool_recyclebin\task\cleanup_category_bin

or run the first via command line.

Cron job running ok?

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

Re: Thousands of backups in the recycle bin even without automated backups

by Eric Phetteplace -
Hi Ken — thanks for the reply! Appreciate it.

The user ID is the admin user (2) for almost all of them. I didn't check every single row but it's clear our users aren't manually doing anything to create thousands of backups.

Recycle bin times were a week but we just yesterday changed them down to 4 days, partially due to this problem. Auto hide is indeed on. Sorry, I may distracted from the main problem by noting how we couldn't even access the backup files. We don't really care about them, the problem is more that manually deleting thousands of backups that are appearing automatically is not scalable. We need to prevent them from being created, not manually delete them. I realize I could disable the recycle bin but obviously that's problematic because there's no granularity to it — we don't want all these backups in there but we do want instructors to be able to use it for their course materials.

The recycle bin tasks are running regularly and that's indicated on the Scheduled Tasks page. They run every half hour. This makes sense to me because the issue is not that the recycle bin isn't being cleared out. All these backups are dated within the time period defined in our bin settings. The issue is that thousands of backups are made on some kind of rolling basis.

I don't see any indication the cron job isn't running. Is there anything I could look for on the cron log? I see a note about auto backups being INACTIVE, notes about the recycle bin cleanup, "Scheduled task complete: Clean backup tables and logs (core\task\backup_cleanup_task)", etc.

Could it be some plugin that's doing this, if there's nothing in Moodle core? We don't have many contributed plugins but we do have some: Attendance mod and block, Zoom, Panopto block and Atto button, Scheduler, grid format, and Ad Hoc Database Queries.
Average of ratings: Useful (1)
In reply to Eric Phetteplace

Re: Thousands of backups in the recycle bin even without automated backups

by Ken Task -
Picture of Particularly helpful Moodlers

Dunno about those addons ... you'd have to look at each one's docs.

Is the clean up task for them working?

If not, you might have to do a moosh file removal ... which should get the file in moodledata/filedir/ sea of files, but also the references in mdl_files table.

No one has ever reported similar ... soooooooo ... very strange.

'SoS', Ken

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

Re: Thousands of backups in the recycle bin even without automated backups

by Eric Phetteplace -
Ah OK. Well I guess it's good to know that this is not normal and work from there. I can investigate the plugins further. I actually was going to do exactly what you suggest — feed a list of these backups to moosh file-delete periodically to wipe them out. It's just I'd far prefer to stop them from ever being created because it appears Moodle is expending resources making (and then deleting) these backups we don't even want.