BUG 8626 Backup issues

PROBLEM  the backup is too bigger to be handle in some os configurations systema files
SOLUTION A new class will help to compress into several files instead one.
         to use the new feature the admin would use and extra option as follow:
         processmaker workspace-backup -s <megabyte max files size> {<workspace>} <destinationFile.tar>
         to restore may use :
         processmaker workspace-restore -m <workspace> <destinationFile.tar> <workspacedestination>
         In both case there are to new arguments -s and -m, these are for use the new feature only, if they are not added the old way is still available.
This commit is contained in:
Ralph Asendeteufrer
2012-10-11 16:54:52 -04:00
parent 5bac8be2aa
commit 463743d3bf
2 changed files with 260 additions and 13 deletions

View File

@@ -52,6 +52,7 @@ EOT
);
CLI::taskArg('workspace', false);
CLI::taskArg('backup-file', true);
CLI::taskOpt("filesize", "Set the max size of the compresed splitted files, by default the max is 1000 Mb.", "s:","filesize=");
CLI::taskRun(run_workspace_backup);
CLI::taskName('workspace-restore');
@@ -70,11 +71,12 @@ CLI::taskArg('backup-file', false);
CLI::taskArg('workspace', true);
CLI::taskOpt("overwrite", "If a workspace already exists, overwrite it.", "o", "overwrite");
CLI::taskOpt("info", "Only shows information about a backup archive.", "i");
CLI::taskOpt("multiple", "Restore from multiple compresed enumerated files.", "m");
CLI::taskOpt("workspace", "Select which workspace to restore if multiple workspaces are present in the archive.",
"w:", "workspace=");
CLI::taskRun(run_workspace_restore);
CLI::taskName('cacheview-repair');
CLI::taskName('cacheview-rep air');
CLI::taskDescription(<<<EOT
Create and populate the APP_CACHE_VIEW table
@@ -374,14 +376,29 @@ function run_workspace_backup($args, $opts) {
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)
if (strpos($filename, "/") === false && strpos($filename, '\\') === false){
$filename = PATH_DATA . "backups/$filename";
}
CLI::logging("Backing up to $filename\n");
$backup = workspaceTools::createBackup($filename);
foreach ($workspaces as $workspace)
$workspace->backup($backup);
$filesize = array_key_exists("filesize", $opts) ? $opts['filesize'] : -1;
if($filesize >= 0)
{
$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) {
@@ -405,8 +422,15 @@ function run_workspace_restore($args, $opts) {
CLI::logging("Restoring from $filename\n");
$workspace = array_key_exists("workspace", $opts) ? $opts['workspace'] : NULL;
$overwrite = array_key_exists("overwrite", $opts);
$multiple = array_key_exists("multiple", $opts);
$dstWorkspace = $args[1];
workspaceTools::restore($filename, $workspace, $dstWorkspace, $overwrite);
//echo "filename: ".$filename." workspace:".$workspace." dts:".$dstWorkspace." over:".$overwrite." multiple:".$multiple."\n";
if(!empty($multiple)){
MultipleFilesBackup::letsRestore ($filename,$workspace,$dstWorkspace,$overwrite);
}
else{
workspaceTools::restore($filename, $workspace, $dstWorkspace, $overwrite);
}
}
}