MDL-28505 Backup: Asynchronous backup and restore
This patch adds asynchronous backup and restore functionality to Moodle. This is an optional feature and is not enabled by default. It can be enabled by site administrators. Asynchronous backup and restores are actioned by the Moodle adhoc task API. The progress of backup and restores is displayedin the Moodle UI. Users can also be sent a message when a backup or restore operation completes via the Moodle messaging API.
This commit is contained in:
@@ -641,4 +641,31 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the progress details of a backup operation.
|
||||
* Get backup records directly from database, if the backup has successfully completed
|
||||
* there will be no controller object to load.
|
||||
*
|
||||
* @param string $backupid The backup id to query.
|
||||
* @return array $progress The backup progress details.
|
||||
*/
|
||||
public static function get_progress($backupid) {
|
||||
global $DB;
|
||||
|
||||
$progress = array();
|
||||
$backuprecord = $DB->get_record(
|
||||
'backup_controllers',
|
||||
array('backupid' => $backupid),
|
||||
'status, progress, operation',
|
||||
MUST_EXIST);
|
||||
|
||||
$status = $backuprecord->status;
|
||||
$progress = $backuprecord->progress;
|
||||
$operation = $backuprecord->operation;
|
||||
|
||||
$progress = array('status' => $status, 'progress' => $progress, 'backupid' => $backupid, 'operation' => $operation);
|
||||
|
||||
return $progress;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user