mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-29262 backup: new setting to control the ttl of backup logs
Add one new backup setting, moving from the general CFG->loglifetime, to be able to delete backup logged information often.
This commit is contained in:
parent
ead4f180a0
commit
14e2704ad4
4 changed files with 36 additions and 9 deletions
|
@ -113,17 +113,18 @@ function cron_run() {
|
|||
}
|
||||
|
||||
|
||||
// Delete old backup_controllers and logs
|
||||
if (!empty($CFG->loglifetime)) { // value in days
|
||||
$loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
|
||||
// Delete child records from backup_logs
|
||||
// Delete old backup_controllers and logs.
|
||||
$loglifetime = get_config('backup', 'loglifetime');
|
||||
if (!empty($loglifetime)) { // Value in days.
|
||||
$loglifetime = $timenow - ($loglifetime * 3600 * 24);
|
||||
// Delete child records from backup_logs.
|
||||
$DB->execute("DELETE FROM {backup_logs}
|
||||
WHERE EXISTS (
|
||||
SELECT 'x'
|
||||
FROM {backup_controllers} bc
|
||||
WHERE bc.backupid = {backup_logs}.backupid
|
||||
AND bc.timecreated < ?)", array($loglifetime));
|
||||
// Delete records from backup_controllers
|
||||
// Delete records from backup_controllers.
|
||||
$DB->execute("DELETE FROM {backup_controllers}
|
||||
WHERE timecreated < ?", array($loglifetime));
|
||||
mtrace(" Deleted old backup records");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue