Skip to content

Commit

Permalink
backup MDL-22184 Scheduled backups are now possible again through cron.
Browse files Browse the repository at this point in the history
AMOS BEGIN
 MOV [move scheduledsetup,core_backup],[automatedsetup,core_backup]
 MOV [scheduledsettings,core_backup],[automatedsettings,core_backup]
 MOV [scheduledstorage,core_backup],[automatedstorage,core_backup]
 MOV [scheduledstoragehelp,core_backup],[automatedstoragehelp,core_backup]
 MOV [scheduledbackupsinactive,core],[automatedbackupsinactive,core_backup]
 MOV [scheduledbackupstatus,core],[automatedbackupstatus,core_backup]
 CPY [schedule,core],[automatedbackupschedule,core_backup]
 MOV [backupschedulehelp,core],[automatedbackupschedulehelp,core_backup]
AMOS END
  • Loading branch information
Sam Hemelryk committed Nov 10, 2010
1 parent 8714216 commit bac233d
Show file tree
Hide file tree
Showing 22 changed files with 723 additions and 66 deletions.
11 changes: 3 additions & 8 deletions admin/report/backups/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@
admin_externalpage_setup('reportbackups');
echo $OUTPUT->header();

/// Scheduled backups are disabled by the server admin
if (!empty($CFG->disablescheduledbackups)) {
print_error('scheduledbackupsdisabled', 'error');
}

/// Scheduled backups aren't active by the site admin
/// Automated backups aren't active by the site admin
$backup_config = backup_get_config();
if (empty($backup_config->backup_sche_active)) {
echo $OUTPUT->notification(get_string('scheduledbackupsinactive'));
if (empty($backup_config->backup_auto_active)) {
echo $OUTPUT->notification(get_string('automatedbackupsinactive', 'backup'));
}

/// Get needed strings
Expand Down
50 changes: 30 additions & 20 deletions admin/settings/courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,18 @@
$ADMIN->add('backups', $temp);

/// "backups" settingpage
$temp = new admin_settingpage('scheduled', get_string('scheduledsettings','backup'), 'moodle/backup:backupcourse');
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_modules', get_string('includemodules'), get_string('backupincludemoduleshelp'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_withuserdata', get_string('includemoduleuserdata'), get_string('backupincludemoduleuserdatahelp'), 0));
$temp->add(new admin_setting_configselect('backup/backup_sche_users', get_string('users'), get_string('backupusershelp'),
0, array(0 => get_string('all'), 1 => get_string('course'))));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_logs', get_string('logs'), get_string('backuplogshelp'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_userfiles', get_string('userfiles'), get_string('backupuserfileshelp'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_coursefiles', get_string('coursefiles'), get_string('backupcoursefileshelp'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_sitefiles', get_string('sitefiles'), get_string('backupsitefileshelp'), 0));
$temp->add(new admin_setting_configcheckbox('backup_sche_gradebook_history', get_string('gradebookhistories', 'grades'), get_string('backupgradebookhistoryhelp'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 0));

$temp = new admin_settingpage('automated', get_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_active', get_string('active'), get_string('backupactivehelp'), 0));
$temp->add(new admin_setting_special_backupdays());
$temp->add(new admin_setting_configtime('backup/backup_auto_hour', 'backup_auto_minute', get_string('executeat'),
get_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
$storageoptions = array(
0 => get_string('storagecourseonly', 'backup'),
1 => get_string('storageexternalonly', 'backup'),
2 => get_string('storagecourseandexternal', 'backup')
);
$temp->add(new admin_setting_configselect('backup/backup_auto_storage', get_string('automatedstorage', 'backup'), get_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
$temp->add(new admin_setting_configdirectory('backup/backup_auto_destination', get_string('saveto'), get_string('backupsavetohelp'), ''));
$keepoptoins = array(
0 => get_string('all'), 1 => '1',
2 => '2',
Expand All @@ -135,13 +134,24 @@
300 => '300',
400 => '400',
500 => '500');
$temp->add(new admin_setting_configselect('backup/backup_sche_keep', get_string('keep'),
get_string('backupkeephelp'), 1, $keepoptoins));
$temp->add(new admin_setting_configcheckbox('backup/backup_sche_active', get_string('active'), get_string('backupactivehelp'), 0));
$temp->add(new admin_setting_special_backupdays());
$temp->add(new admin_setting_configtime('backup/backup_sche_hour', 'backup_sche_minute', get_string('executeat'),
get_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
$temp->add(new admin_setting_configdirectory('backup/backup_sche_destination', get_string('saveto'), get_string('backupsavetohelp'), ''));
$temp->add(new admin_setting_configselect('backup/backup_auto_keep', get_string('keep'), get_string('backupkeephelp'), 1, $keepoptoins));


$temp->add(new admin_setting_heading('automatedsettings', get_string('automatedsettings','backup'), ''));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', get_string('users'), get_string('backupusershelp'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', get_string('generalroleassignments','backup'), get_string('configgeneralroleassignments','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_user_files', get_string('generaluserfiles', 'backup'), get_string('configgeneraluserfiles','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', get_string('generalactivities','backup'), get_string('configgeneralactivities','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', get_string('generalblocks','backup'), get_string('configgeneralblocks','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', get_string('generalfilters','backup'), get_string('configgeneralfilters','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', get_string('generalcomments','backup'), get_string('configgeneralcomments','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', get_string('generaluserscompletion','backup'), get_string('configgeneraluserscompletion','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', get_string('logs'), get_string('backuplogshelp'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', get_string('generalhistories','backup'), get_string('configgeneralhistories','backup'), 0));


//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0));
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 0));

$ADMIN->add('backups', $temp);

Expand Down
9 changes: 5 additions & 4 deletions backup/backup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ abstract class backup implements checksumable {
const INTERACTIVE_NO = false;

// Predefined modes (purposes) of the backup
const MODE_GENERAL = 10;
const MODE_IMPORT = 20;
const MODE_HUB = 30;
const MODE_SAMESITE = 40;
const MODE_GENERAL = 10;
const MODE_IMPORT = 20;
const MODE_HUB = 30;
const MODE_SAMESITE = 40;
const MODE_AUTOMATED = 50;

// Target (new/existing/current/adding/deleting)
const TARGET_CURRENT_DELETING = 0;
Expand Down
2 changes: 1 addition & 1 deletion backup/controller/backup_controller.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class backup_controller extends backup implements loggable {
* @param int $id The ID of the item to backup; e.g the course id
* @param int $format The backup format to use; Most likely backup::FORMAT_MOODLE
* @param bool $interactive Whether this backup will require user interaction; backup::INTERACTIVE_YES or INTERACTIVE_NO
* @param int $mode One of backup::MODE_GENERAL, MODE_IMPORT, MODE_SAMESITE, MODE_HUB
* @param int $mode One of backup::MODE_GENERAL, MODE_IMPORT, MODE_SAMESITE, MODE_HUB, MODE_AUTOMATED
* @param int $userid The id of the user making the backup
*/
public function __construct($type, $id, $format, $interactive, $mode, $userid){
Expand Down
16 changes: 16 additions & 0 deletions backup/restorefile.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,20 @@
echo $renderer->backup_files_viewer($treeview_options);
echo $OUTPUT->container_end();

$automatedbackups = get_config('backup', 'backup_auto_active');
if (!empty($automatedbackups)) {
echo $OUTPUT->heading_with_help(get_string('choosefilefromautomatedbackup', 'backup'), 'choosefilefromautomatedbackup', 'backup');
echo $OUTPUT->container_start();
$treeview_options = array();
$user_context = get_context_instance(CONTEXT_USER, $USER->id);
$treeview_options['filecontext'] = $context;
$treeview_options['currentcontext'] = $context;
$treeview_options['component'] = 'backup';
$treeview_options['context'] = $context;
$treeview_options['filearea'] = 'automated';
$renderer = $PAGE->get_renderer('core', 'backup');
echo $renderer->backup_files_viewer($treeview_options);
echo $OUTPUT->container_end();
}

echo $OUTPUT->footer();
Loading

0 comments on commit bac233d

Please sign in to comment.