So it appears that changing the config of autobackups to a designated directory only didn't clean up auto backups that existed in /moodledata/filedir/. Right?
This one:
"(Deleting the automatied backup in the course backend does not delete neither the backup in filedir nor the backup in the new folder) (<- was just testing)"
When one deletes files via Moodle UX, they get moved to trashdir and are finally erased when cron job sees (4 days later?) files in trashdir have not been relinked.
So what does a cron run/task (run now) for trashdir look like?
Not sure moodle can find and clean up automated backups after a change of config like that ... that's why in the other posting you found, moosh was suggested. If I re-call correctly, moosh does two things ... cleans up the rows in mdl_files *and* removes the files from /moodledata/filedir those rows referenced as well.
One cannot avoid interacting with DB tables in this case, me thinks ... one doesn't want 'orphaned' references in DB or 'orphaned' files physically present in moodledata/filedir/
BTW, a backup could exist in teachers private files area. Admin's cannot see those unless one logs in as the teacher, *pretends* to restore a course. Can then manage backups seen in private files (ie, delete) and then cancel the restore. That could be too much for admin to do ... thus moosh.
Me thinks you could modify the query to seek what backup files reside in 'private' areas - I'll let you tinker with that!
'spirit of sharing', Ken