mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-45714 backup: Less aggressive removal of old backup dirs
The old 4 hour standard was too aggressive and can cause backup files to be removed while they were still in use. Now the same as cron, 1 week.
This commit is contained in:
parent
1132d30d1f
commit
0babaf208d
2 changed files with 7 additions and 9 deletions
|
@ -28,8 +28,7 @@
|
|||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* create the temp dir where backup/restore will happen,
|
||||
* delete old directories and create temp ids table
|
||||
* Create the temp dir where backup/restore will happen and create temp ids table.
|
||||
*/
|
||||
class create_and_clean_temp_stuff extends backup_execution_step {
|
||||
|
||||
|
@ -38,7 +37,6 @@ class create_and_clean_temp_stuff extends backup_execution_step {
|
|||
$progress->start_progress('Deleting backup directories');
|
||||
backup_helper::check_and_create_backup_dir($this->get_backupid());// Create backup temp dir
|
||||
backup_helper::clear_backup_dir($this->get_backupid(), $progress); // Empty temp dir, just in case
|
||||
backup_helper::delete_old_backup_dirs(time() - (4 * 60 * 60), $progress); // Delete > 4 hours temp dirs
|
||||
backup_controller_dbops::drop_backup_ids_temp_table($this->get_backupid()); // Drop ids temp table
|
||||
backup_controller_dbops::create_backup_ids_temp_table($this->get_backupid()); // Create ids temp table
|
||||
$progress->end_progress();
|
||||
|
@ -46,11 +44,11 @@ class create_and_clean_temp_stuff extends backup_execution_step {
|
|||
}
|
||||
|
||||
/**
|
||||
* delete the temp dir used by backup/restore (conditionally),
|
||||
* delete old directories and drop tem ids table. Note we delete
|
||||
* Delete the temp dir used by backup/restore (conditionally),
|
||||
* delete old directories and drop temp ids table. Note we delete
|
||||
* the directory but not the corresponding log file that will be
|
||||
* there for, at least, 4 hours - only delete_old_backup_dirs()
|
||||
* deletes log files (for easier access to them)
|
||||
* there for, at least, 1 week - only delete_old_backup_dirs() or cron
|
||||
* deletes log files (for easier access to them).
|
||||
*/
|
||||
class drop_and_clean_temp_stuff extends backup_execution_step {
|
||||
|
||||
|
@ -60,7 +58,7 @@ class drop_and_clean_temp_stuff extends backup_execution_step {
|
|||
global $CFG;
|
||||
|
||||
backup_controller_dbops::drop_backup_ids_temp_table($this->get_backupid()); // Drop ids temp table
|
||||
backup_helper::delete_old_backup_dirs(time() - (4 * 60 * 60)); // Delete > 4 hours temp dirs
|
||||
backup_helper::delete_old_backup_dirs(strtotime('-1 week')); // Delete > 1 week old temp dirs.
|
||||
// Delete temp dir conditionally:
|
||||
// 1) If $CFG->keeptempdirectoriesonbackup is not enabled
|
||||
// 2) If backup temp dir deletion has been marked to be avoided
|
||||
|
|
|
@ -67,7 +67,7 @@ class restore_drop_and_clean_temp_stuff extends restore_execution_step {
|
|||
restore_controller_dbops::drop_restore_temp_tables($this->get_restoreid()); // Drop ids temp table
|
||||
$progress = $this->task->get_progress();
|
||||
$progress->start_progress('Deleting backup dir');
|
||||
backup_helper::delete_old_backup_dirs(time() - (4 * 60 * 60), $progress); // Delete > 4 hours temp dirs
|
||||
backup_helper::delete_old_backup_dirs(strtotime('-1 week'), $progress); // Delete > 1 week old temp dirs.
|
||||
if (empty($CFG->keeptempdirectoriesonbackup)) { // Conditionally
|
||||
backup_helper::delete_backup_dir($this->task->get_tempdir(), $progress); // Empty restore dir
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue