Skip to content

Commit

Permalink
Modified to delete temp files older than 4 hours (previously it was
Browse files Browse the repository at this point in the history
configured to 48 hours). Force to execute the clean before doing the
backup itself. This should avoid the disk full of temp backup files
issue. See bug 1520.
http://moodle.org/bugs/bug.php?op=show&bugid=1520
  • Loading branch information
stronk7 committed Jun 27, 2004
1 parent 20761eb commit 1194026
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions backup/backup_scheduled.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,15 @@ function schedule_backup_course_execute($preferences,$starttime = 0) {
//Create them as needed
schedule_backup_log($starttime,$preferences->backup_course," checking temp structures");
$status = check_and_create_backup_dir($preferences->backup_unique_code);
//Empty dir
//Empty backup dir
if ($status) {
schedule_backup_log($starttime,$preferences->backup_course," cleaning old data");
schedule_backup_log($starttime,$preferences->backup_course," cleaning current dir");
$status = clear_backup_dir($preferences->backup_unique_code);
}

//Delete old_entries from backup tables
if ($status) {
schedule_backup_log($starttime,$preferences->backup_course," cleaning old data");
$status = backup_delete_old_data();
}

Expand Down
6 changes: 3 additions & 3 deletions backup/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ function backup_get_config() {
}

//Delete old data in backup tables (if exists)
//Two days seems to be apropiate
//Four hours seem to be appropiate now that backup is stable
function backup_delete_old_data() {

global $CFG;

//Change this if you want !!
$days = 2;
$hours = 4;
//End change this
$seconds = $days * 24 * 60 * 60;
$seconds = $hours * 60 * 60;
$delete_from = time()-$seconds;
//Now delete from tables
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
Expand Down
2 changes: 1 addition & 1 deletion backup/restore_precheck.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
$backup_unique_code = time();

//Now check and create the backup dir (if it doesn't exist)
echo "<li>".get_string("creatingtemporarystructures");
$status = check_and_create_backup_dir($backup_unique_code);
//Empty dir
if ($status) {
echo "<li>".get_string("creatingtemporarystructures");
$status = clear_backup_dir($backup_unique_code);
}

Expand Down

0 comments on commit 1194026

Please sign in to comment.