MDL-21432 backup - added operation to separate backup & restore

This commit is contained in:
Eloy Lafuente
2010-07-05 16:37:50 +00:00
parent 37fb7c0e1d
commit f60f4666f9
7 changed files with 96 additions and 23 deletions
+17 -11
View File
@@ -51,6 +51,7 @@ class backup_controller extends backup implements loggable {
protected $interactive; // yes/no
protected $mode; // Purpose of the backup (default settings)
protected $userid; // user id executing the backup
protected $operation; // Type of operation (backup/restore)
protected $status; // Current status of the controller (created, planned, configured...)
@@ -75,6 +76,7 @@ class backup_controller extends backup implements loggable {
// Apply some defaults
$this->execution = backup::EXECUTION_INMEDIATE;
$this->operation = backup::OPERATION_BACKUP;
$this->executiontime = 0;
$this->checksum = '';
@@ -179,6 +181,7 @@ class backup_controller extends backup implements loggable {
'interactive-'. $this->interactive .
'mode-' . $this->mode .
'userid-' . $this->userid .
'operation-' . $this->operation .
'status-' . $this->status .
'execution-' . $this->execution .
'plan-' . backup_general_helper::array_checksum_recursive(array($this->plan)) .
@@ -200,6 +203,10 @@ class backup_controller extends backup implements loggable {
return $this->type;
}
public function get_operation() {
return $this->operation;
}
public function get_id() {
return $this->id;
}
@@ -259,17 +266,6 @@ class backup_controller extends backup implements loggable {
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
}
// Protected API starts here
protected function calculate_backupid() {
// Current epoch time + type + id + format + interactive + mode + userid
// should be unique enough. Add one random part at the end
$this->backupid = md5(time() . '-' . $this->type . '-' . $this->id . '-' . $this->format . '-' .
$this->interactive . '-' . $this->mode . '-' . $this->userid . '-' .
random_string(20));
}
public function save_controller() {
// Going to save controller to persistent storage, calculate checksum for later checks and save it
// TODO: flag the controller as NA. Any operation on it should be forbidden util loaded back
@@ -286,6 +282,16 @@ class backup_controller extends backup implements loggable {
return $controller;
}
// Protected API starts here
protected function calculate_backupid() {
// Current epoch time + type + id + format + interactive + mode + userid + operation
// should be unique enough. Add one random part at the end
$this->backupid = md5(time() . '-' . $this->type . '-' . $this->id . '-' . $this->format . '-' .
$this->interactive . '-' . $this->mode . '-' . $this->userid . '-' .
$this->operation . '-' . random_string(20));
}
protected function load_plan() {
$this->log('loading controller plan', backup::LOG_DEBUG);
$this->plan = new backup_plan($this);