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:
Matt Porritt 2018-12-10 12:27:26 +11:00 committed by Mark Nelson
parent f622ee97e3
commit d7e4481e98
17 changed files with 190 additions and 18 deletions

View file

@ -150,6 +150,13 @@ if (!async_helper::is_async_pending($id, 'course', 'backup')) {
$loghtml = '';
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
// Before we perform the backup check settings to see if user
// or setting defaults are set to exclude files from the backup.
if ($backup->get_setting_value('files') == 0) {
$bc->set_mode(backup::MODE_SAMESITE);
$renderer->set_samesite_notification();
}
if ($backupmode != backup::MODE_ASYNC) {
// Synchronous backup handling.
@ -180,6 +187,7 @@ if (!async_helper::is_async_pending($id, 'course', 'backup')) {
// Hide the progress display and first backup step bar (the 'finished' step will show next).
echo html_writer::end_div();
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
} else {
// Async backup handling.
$backup->get_controller()->finish_ui();
@ -203,6 +211,8 @@ if (!async_helper::is_async_pending($id, 'course', 'backup')) {
'restoreurl' => $restoreurl->out(),
'headingident' => 'backup'
);
echo $renderer->set_samesite_notification();
echo $renderer->render_from_template('core/async_backup_status', $progresssetup);
}