PM-401 Backup workspace modified
Backup database modified
This commit is contained in:
@@ -372,60 +372,64 @@ function run_drafts_clean($args, $opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run_workspace_backup($args, $opts) {
|
function run_workspace_backup($args, $opts) {
|
||||||
$workspaces = array();
|
$workspaces = array();
|
||||||
if (sizeof($args) > 2) {
|
if (sizeof($args) > 2) {
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
foreach ($args as $arg) {
|
foreach ($args as $arg) {
|
||||||
$workspaces[] = new workspaceTools($arg);
|
$workspaces[] = new workspaceTools($arg);
|
||||||
|
}
|
||||||
|
} else if (sizeof($args) > 0) {
|
||||||
|
$workspace = new workspaceTools($args[0]);
|
||||||
|
$workspaces[] = $workspace;
|
||||||
|
if (sizeof($args) == 2) {
|
||||||
|
$filename = $args[1];
|
||||||
|
} else {
|
||||||
|
$filename = "{$workspace->name}.tar";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception("No workspace specified for backup");
|
||||||
}
|
}
|
||||||
} else if (sizeof($args) > 0) {
|
|
||||||
$workspace = new workspaceTools($args[0]);
|
|
||||||
$workspaces[] = $workspace;
|
|
||||||
if (sizeof($args) == 2)
|
|
||||||
$filename = $args[1];
|
|
||||||
else
|
|
||||||
$filename = "{$workspace->name}.tar";
|
|
||||||
} else {
|
|
||||||
throw new Exception("No workspace specified for backup");
|
|
||||||
}
|
|
||||||
foreach ($workspaces as $workspace)
|
|
||||||
if (!$workspace->workspaceExists())
|
|
||||||
throw new Exception("Workspace '{$workspace->name}' not found");
|
|
||||||
//If this is a relative path, put the file in the backups directory
|
|
||||||
if (strpos($filename, "/") === false && strpos($filename, '\\') === false){
|
|
||||||
$filename = PATH_DATA . "backups/$filename";
|
|
||||||
}
|
|
||||||
CLI::logging("Backing up to $filename\n");
|
|
||||||
|
|
||||||
$filesize = array_key_exists("filesize", $opts) ? $opts['filesize'] : -1;
|
|
||||||
if($filesize >= 0)
|
foreach ($workspaces as $workspace) {
|
||||||
{
|
if (!$workspace->workspaceExists()) {
|
||||||
if(!Bootstrap::isLinuxOs()){
|
throw new Exception("Workspace '{$workspace->name}' not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//If this is a relative path, put the file in the backups directory
|
||||||
|
if (strpos($filename, "/") === false && strpos($filename, '\\') === false){
|
||||||
|
$filename = PATH_DATA . "backups/$filename";
|
||||||
|
}
|
||||||
|
CLI::logging("Backing up to $filename\n");
|
||||||
|
|
||||||
|
$filesize = array_key_exists("filesize", $opts) ? $opts['filesize'] : -1;
|
||||||
|
|
||||||
|
if ($filesize >= 0) {
|
||||||
|
if (!Bootstrap::isLinuxOs()) {
|
||||||
CLI::error("This is not a Linux enviroment, cannot use this filesize [-s] feature.\n");
|
CLI::error("This is not a Linux enviroment, cannot use this filesize [-s] feature.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$multipleBackup = new multipleFilesBackup ($filename,$filesize);//if filesize is 0 the default size will be took
|
$multipleBackup = new multipleFilesBackup ($filename,$filesize);//if filesize is 0 the default size will be took
|
||||||
//using new method
|
//using new method
|
||||||
foreach ($workspaces as $workspace){
|
foreach ($workspaces as $workspace) {
|
||||||
$multipleBackup->addToBackup($workspace);
|
$multipleBackup->addToBackup($workspace);
|
||||||
}
|
}
|
||||||
$multipleBackup->letsBackup();
|
$multipleBackup->letsBackup();
|
||||||
}
|
} else {
|
||||||
else
|
//ansient method to backup into one large file
|
||||||
{
|
$backup = workspaceTools::createBackup($filename);
|
||||||
//ansient method to backup into one large file
|
|
||||||
$backup = workspaceTools::createBackup($filename);
|
|
||||||
|
|
||||||
foreach ($workspaces as $workspace)
|
foreach ($workspaces as $workspace) {
|
||||||
$workspace->backup($backup);
|
$workspace->backup($backup);
|
||||||
}
|
}
|
||||||
CLI::logging("\n");
|
}
|
||||||
workspaceTools::printSysInfo();
|
|
||||||
foreach ($workspaces as $workspace) {
|
|
||||||
CLI::logging("\n");
|
CLI::logging("\n");
|
||||||
$workspace->printMetadata(false);
|
workspaceTools::printSysInfo();
|
||||||
}
|
foreach ($workspaces as $workspace) {
|
||||||
|
CLI::logging("\n");
|
||||||
|
$workspace->printMetadata(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_workspace_restore($args, $opts) {
|
function run_workspace_restore($args, $opts) {
|
||||||
|
|||||||
@@ -1032,10 +1032,14 @@ class workspaceTools
|
|||||||
|
|
||||||
$wfDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_USER'] . ':' . $fields['DB_PASS'] . '@' . $fields['DB_HOST'] . '/' . $fields['DB_NAME'];
|
$wfDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_USER'] . ':' . $fields['DB_PASS'] . '@' . $fields['DB_HOST'] . '/' . $fields['DB_NAME'];
|
||||||
|
|
||||||
|
if ($fields['DB_NAME'] == $fields['DB_RBAC_NAME']) {
|
||||||
|
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'], 'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'MySql Version' => $fields['DATABASE']);
|
||||||
|
} else {
|
||||||
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'],
|
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'],
|
||||||
//'Available Databases' => $fields['AVAILABLE_DB'],
|
//'Available Databases' => $fields['AVAILABLE_DB'],
|
||||||
'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE']
|
'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE']
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($info as $k => $v) {
|
foreach ($info as $k => $v) {
|
||||||
if (is_numeric($k)) {
|
if (is_numeric($k)) {
|
||||||
@@ -1073,11 +1077,14 @@ class workspaceTools
|
|||||||
|
|
||||||
if ($onedb) {
|
if ($onedb) {
|
||||||
$databases = array("rb", "rp");
|
$databases = array("rb", "rp");
|
||||||
|
} else if ($dbInfo['DB_NAME'] == $dbInfo['DB_RBAC_NAME']) {
|
||||||
|
$databases = array("wf");
|
||||||
} else {
|
} else {
|
||||||
$databases = array("wf", "rp", "rb");
|
$databases = array("wf", "rp", "rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbNames = array();
|
$dbNames = array();
|
||||||
|
|
||||||
foreach ($databases as $db) {
|
foreach ($databases as $db) {
|
||||||
$dbInfo = $this->getDBCredentials($db);
|
$dbInfo = $this->getDBCredentials($db);
|
||||||
$oDbMaintainer = new DataBaseMaintenance($dbInfo["host"], $dbInfo["user"], $dbInfo["pass"]);
|
$oDbMaintainer = new DataBaseMaintenance($dbInfo["host"], $dbInfo["user"], $dbInfo["pass"]);
|
||||||
|
|||||||
Reference in New Issue
Block a user