function test_get_list_backups() { $backuplist = get_list_backups('1'); if (!empty($backuplist)) { $this->assertTrue(true); } }
function generate_incrementals($courseid) { global $CFG; //check XDELTA is installed. if (!check_xdelta_installed()) { mtrace(get_string('xdeltanotinstalled', 'local')); return false; } $incremental_config = backup_get_config(); //set directory paths if (!empty($incremental_config->backup_inc_destination)) { $backuppath = $incremental_config->backup_inc_destination . '/' . $courseid . '/'; } else { $backuppath = $CFG->dataroot . '/' . $courseid . '/backupdata/'; } $backuplist = get_list_backups($courseid); $latestbackup = $backuplist[0]; foreach ($backuplist as $id => $backup) { if ($id != 0) { if (!create_incremental($courseid, $backup, $latestbackup)) { //don't generate any more incrementals as the $backup is the same as $latestbackup and we don't need to keep this backup at all. unlink($backuppath . $latestbackup); //delete new backup as it isn't needed. mtrace(get_string('coursenotchanged', 'local')); break; //stop running more incrementals. } } } //now cleanup incremental files that are no longer needed. $incrementallist = get_list_backups($courseid, true); foreach ($incrementallist as $incremental) { $findstr = strpos($incremental, md5($latestbackup)); if (!$findstr) { unlink($backuppath . 'incrementals/' . $incremental); } } return true; }