Write and external script to delete manual backups possible?

Re: Write and external script to delete manual backups possible?

by Davo Smith -
Number of replies: 1
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well, you'd have to look in the database for your system to check, but the SQL query is going to look something like:

$sql = "SELECT * FROM {files} WHERE component = 'user' AND filearea = 'backup' AND timemodified < :time";

$params = ['time' => time() - (6 * 30 * DAYSECS)];

$files = $DB->get_records_sql($sql, $params);

But, again, you'd have to look in your database to double-check exactly which 'filearea' and 'component' values you are looking for (the local DB only has a 'no user' backup, which, from memory, I think are stored slightly differently).

In reply to Davo Smith

Re: Write and external script to delete manual backups possible?

by Jerry Lau -

will these files be move to the /trash directory and when the cron is run, it will delete them right?