mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-35773 Backup: API should have option to not backup files
Allow both UI and automated backups to be created without including files. Instead include only file references. This is essentially implementing "SAMESITE" to backup files instead of only for import and export functionality. A new backup setting to include files (defaults to yes) has been included. The restore process will also look for and attempt to restore files from the trashdir as part of restoring backups. Additionally to support this process the ammount of time files are kept in trashdir before they are cleaned up via cron is also adjustable via admin setting.
This commit is contained in:
parent
f622ee97e3
commit
d7e4481e98
17 changed files with 190 additions and 18 deletions
|
@ -185,6 +185,20 @@ class backup_controller extends base_controller {
|
|||
backup_check::check_security($this, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mode (purpose) of the backup.
|
||||
*
|
||||
* @param int $mode The mode to set.
|
||||
*/
|
||||
public function set_mode($mode) {
|
||||
$this->mode = $mode;
|
||||
$this->set_include_files(); // Need to check if files are included as mode may have changed.
|
||||
$this->save_controller();
|
||||
$tbc = self::load_controller($this->backupid);
|
||||
$this->logger = $tbc->logger; // Wakeup loggers.
|
||||
$tbc->plan->destroy(); // Clean plan controller structures, keeping logger alive.
|
||||
}
|
||||
|
||||
public function set_status($status) {
|
||||
// Note: never save_controller() with the object info after STATUS_EXECUTING or the whole controller,
|
||||
// containing all the steps will be sent to DB. 100% (monster) useless.
|
||||
|
@ -410,6 +424,13 @@ class backup_controller extends base_controller {
|
|||
$includefiles = false;
|
||||
}
|
||||
|
||||
// If backup is automated and we have set auto backup config to exclude
|
||||
// files then set them to be excluded here.
|
||||
$backupautofiles = (bool)get_config('backup', 'backup_auto_files');
|
||||
if ($this->get_mode() === backup::MODE_AUTOMATED && !$backupautofiles) {
|
||||
$includefiles = false;
|
||||
}
|
||||
|
||||
$this->includefiles = (int) $includefiles;
|
||||
$this->log("setting file inclusion to {$this->includefiles}", backup::LOG_DEBUG);
|
||||
return $this->includefiles;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue