public function createBackupForCourse($session, $id) { global $Out; // Does the item exist locally $record = get_record("course", "id", "{$id}", null, null, null, null, "id"); $Out->print_r($record, '$record = ', 0, true); global $CFG; if (empty($record)) { return false; } $preferences = $this->getOrCreateSessionBackupPreferences($session); // yes: make a backup and include the synch logs $this->appendPreferencesForCoreBackup($preferences); $this->appendPreferencesForCourseBackup(&$preferences, $id); $preferences->backup_generate_incrementals = true; // Ensure incrementals are created $this->setBackupPreferences($preferences); $CFG->backup_preferences = $preferences; $message = ''; $Out->print_r($preferences, '$preferences = ', 0, true); return backup_execute($preferences, $message); }
/** * Function to backup an entire course silently and create a zipfile. * * @param int $courseid the id of the course * @param array $prefs see {@link backup_generate_preferences_artificially} */ function backup_course_silently($courseid, $prefs, &$errorstring) { global $CFG, $preferences, $DB; // global preferences here because something else wants it :( if (!defined('BACKUP_SILENTLY')) { define('BACKUP_SILENTLY', 1); } if (!($course = $DB->get_record('course', array('id' => $courseid)))) { debugging("Couldn't find course with id {$courseid} in backup_course_silently"); return false; } $preferences = backup_generate_preferences_artificially($course, $prefs); if (backup_execute($preferences, $errorstring)) { return $CFG->dataroot . '/' . $course->id . '/backupdata/' . $preferences->backup_name; } else { return false; } }
/** * Function to backup an entire course silently and create a zipfile. * * @param int $courseid the id of the course * @param array $prefs see {@link backup_generate_preferences_artificially} */ function rollover_backup_course_silently($courseid, $prefs, &$errorstring) { global $CFG, $preferences; // global preferences here because something else wants it :( if (!defined('BACKUP_SILENTLY')) { define('BACKUP_SILENTLY', 1); } if (!($course = get_record('course', 'id', $courseid))) { debugging("Couldn't find course with id {$courseid} in backup_course_silently"); return false; } $preferences = rollover_backup_generate_preferences_artificially($course, $prefs); $preferences->elis_skip_zip = true; if (backup_execute($preferences, $errorstring)) { return $preferences->backup_unique_code; } else { return false; } }