PM-401 Backup workspace modified

Backup database modified
This commit is contained in:
norahmollo
2014-10-10 15:09:26 -04:00
parent 0e8b0c013d
commit b928436008
2 changed files with 62 additions and 51 deletions

View File

@@ -372,60 +372,64 @@ function run_drafts_clean($args, $opts) {
}
function run_workspace_backup($args, $opts) {
$workspaces = array();
if (sizeof($args) > 2) {
$filename = array_pop($args);
foreach ($args as $arg) {
$workspaces[] = new workspaceTools($arg);
$workspaces = array();
if (sizeof($args) > 2) {
$filename = array_pop($args);
foreach ($args as $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)
{
if(!Bootstrap::isLinuxOs()){
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) {
if (!Bootstrap::isLinuxOs()) {
CLI::error("This is not a Linux enviroment, cannot use this filesize [-s] feature.\n");
return;
}
$multipleBackup = new multipleFilesBackup ($filename,$filesize);//if filesize is 0 the default size will be took
//using new method
foreach ($workspaces as $workspace){
$multipleBackup->addToBackup($workspace);
}
$multipleBackup->letsBackup();
}
else
{
//ansient method to backup into one large file
$backup = workspaceTools::createBackup($filename);
}
$multipleBackup = new multipleFilesBackup ($filename,$filesize);//if filesize is 0 the default size will be took
//using new method
foreach ($workspaces as $workspace) {
$multipleBackup->addToBackup($workspace);
}
$multipleBackup->letsBackup();
} else {
//ansient method to backup into one large file
$backup = workspaceTools::createBackup($filename);
foreach ($workspaces as $workspace)
$workspace->backup($backup);
}
CLI::logging("\n");
workspaceTools::printSysInfo();
foreach ($workspaces as $workspace) {
foreach ($workspaces as $workspace) {
$workspace->backup($backup);
}
}
CLI::logging("\n");
$workspace->printMetadata(false);
}
workspaceTools::printSysInfo();
foreach ($workspaces as $workspace) {
CLI::logging("\n");
$workspace->printMetadata(false);
}
}
function run_workspace_restore($args, $opts) {