Unable to delete backups

Unable to delete backups

Cynthia McKinley -
回帖数:7
For the past 6 months, I have been unable to delete course backups.  I can create backups, restore, and download.  But when I click on "Manage backups" the manage backup page opens with no files listed (see attached image).  I am running Moodle through Hostgator and the software was installed using Softaculous (moodle 3.9.1).  I have tried Chrome, Android, & Firefox and I have cleared all caches but the page is always blank.  I've been unable to find the backup files via the Hostgator file manager (searched for mbz files in Moodledata as well as entire site).
附件 Screenshot (560).png
回复Cynthia McKinley

Re: Unable to delete backups

Ken Task -
Particularly helpful Moodlers的头像

Backups of courses in moodle are not stored in moodledata/filedir/ with humanly recognizable names with extensions (like .mbz), but rather, by it's own file system.

What's your role in the moodle?   Admin?

What path (what did you click upon) to arrive at what you show in your screen shot ... shows you are in a course.

Are you running auomated backups?

If so, what is the setting for "Automated backup storage".  And is there anything in the 'Save to' box?

'SoS', Ken


回复Ken Task

Re: Unable to delete backups

Cynthia McKinley -
Thanks for the help. I am admin and teacher. When I click on "Restore" it takes me to the Restore Course page with "Course Backup Area," "User Private Backup Area," and "Automated Backups" headings. Each of those headings has a list of files (with the option to Download or Restore) and the "manage backup files" button. When I click on the "Manage backup files" button, it should show the same files listed under a heading (ie, User Private has 28 files listed), but it's always blank. It's as if the page isn't even trying to load the file names.

I have automated backups turned on. It is set to store in the Course Backup File Area, and the Save to box is empty. I know it's working because on the Restore page, I can download the backup files. I just can't delete them if the manage files page won't load. It used to work, but I'm not exactly sure what changed in the past year.
回复Cynthia McKinley

Re: Unable to delete backups

Ken Task -
Particularly helpful Moodlers的头像

Have you had debugging turned on to see if there is something going on?

All of your backups are going to moodledata/filedir/ ... but not by humanly recognizable names/extensions (.mbz).   So, assuming you have something like phpmyadmin and could query the DB let's see what the following query shows:

select contenthash,filename,component from mdl_files where (filename like '%.mbz' and component= 'backup')

Example of what the query above should show:

contenthash    filename    component
35584c737a95f204c9180c9d34702919ccc1ed31    backup-moodle2-course-1-m311-20220420-1250.mbz    backup
22e053ff117cd00262aa8e07eb4f73a6048af4ab    backup-moodle2-course-2-sa-20220614-1550.mbz    backup
c0e13307a6470613451a4453f2abde53ba8c49db    backup-moodle2-course-2-sa-20220615-1550.mbz    backup

The contenthash value is really the location in moodledata/filedir/ AND the name of the file in the Moodle file system.

Taking the first one above:

35584c737a95f204c9180c9d34702919ccc1ed31

is in moodledata/filedir/35/58/ and the filename is 35584c737a95f204c9180c9d34702919ccc1ed31

'SoS', Ken

回复Ken Task

Re: Unable to delete backups

Cynthia McKinley -
Awesome. I'm making progress. I had to change mdl_files to mdllc_files and it listed all of the automatic backups. I deleted those and they no longer are showing in Moodle. However, the "user private backup area" files are still in Moodle, even after clearing my cache. I have 28 files there that I want to delete. Can I delete all of the files with component "backup" using this query? Or is that a bad idea?
select contenthash,filename,component from mdllc_files where (component= 'backup')

(Note: I'm a tutor who uses Moodle for online tutoring, but I know virtually nothing about website and db management, so this is an awesome learning opportunity for me. You're a great teacher!)
回复Cynthia McKinley

Re: Unable to delete backups

Ken Task -
Particularly helpful Moodlers的头像

Thanks for compliment, but ... may have led you to a condition where your site now has 'orphaned files' in moodledata/filedir/!

So when you say:

"I deleted those and they no longer are showing in Moodle"

Deleted what - the rows in the DB?   If you deleted the rows in the DB mdl_files table that's half of what you need to do ... you need also to remove the contenthash named files in moodledata/filedir/ - *very carefully* or you end up with 'orphaned files' (files in moodledata/filedir/ that Moodle now longer knows about nor displays)!

One should never have to do this really.  And it's never a good idea to manipulate the DB manually.

So, sounds like the automated backup is confused?

There should be a report for automated backups.  Check that out.   Could be the scheduling is confused ... date for next run.

I know it's more work, but safer to deleted files in private area using the moodle admin interface!

Anyhoo ... clean up is first order of business ... then consider turning off autobackups and force yourself to do backups manually for a little while! 微笑

'SoS', Ken


回复Ken Task

Re: Unable to delete backups

Cynthia McKinley -
Luckily, I had a backup of the database before I made any of those edits, so I restored it and then went back and deleted the files in moodledata at the same time that I deleted the rows in the DB mdl-files table. That seems to have removed all of the automatic backups.

However, the ones I really need to clean out are the manual backups, since I have duplicates of older courses. (I actually use manual backups much more than auto & have no problem turning off autobackup.) These backups don't show up in the database query that you gave me. Are they in a different location in the database?

( To recap - I'm unable to delete backups inside Moodle: The user private area backups shows 21 backup courses. I AM able to download these, but when I click "manage backups" the following page the list is empty. Similarly, when I click on the "Private Files" link in the dashboard, the list is empty.)
回复Cynthia McKinley

Re: Unable to delete backups

Ken Task -
Particularly helpful Moodlers的头像

Change the query from:

select contenthash,filename,component from mdl_files where (filename like '%.mbz' and component= 'backup')

to

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

There is a plug in you might want to install to help short this out:

https://moodle.org/plugins/report_allbackups/versions

'SoS', Ken