PM-3035 workspace backup/restore issues SOLVED
This commit is contained in:
@@ -51,7 +51,7 @@ EOT
|
||||
);
|
||||
CLI::taskArg('workspace', false);
|
||||
CLI::taskArg('backup-file', true);
|
||||
CLI::taskOpt("filesize", "Split the backup file in multiple files which are compressed. The maximum size of these files is set to MAX-SIZE in megabytes. If MAX-SIZE is not set, then it is 1000 megabytes by default. It may be necessary to use this option if using a 32 bit Linux/UNIX system which limits its maximum file size to 2GB. This option does not work on Windows systems.", "sMAX-SIZE","filesize=MAX-SIZE");
|
||||
CLI::taskOpt("filesize", "Split the backup file in multiple files which are compressed. The maximum size of these files is set to MAX-SIZE in megabytes. If MAX-SIZE is not set, then it is 1000 megabytes by default. It may be necessary to use this option if using a 32 bit Linux/UNIX system which limits its maximum file size to 2GB. This option does not work on Windows systems.", "s:","filesize=");
|
||||
CLI::taskRun("run_workspace_backup");
|
||||
|
||||
CLI::taskName('workspace-restore');
|
||||
@@ -73,9 +73,9 @@ CLI::taskOpt("info", "Show information about backup file, but do not restore any
|
||||
CLI::taskOpt("multiple", "Restore from multiple compressed backup files which are numbered.", "m");
|
||||
CLI::taskOpt("workspace", "Specify which workspace to restore if multiple workspaces are present in the backup file.
|
||||
Ex: -wworkflow.",
|
||||
"wWORKSPACE", "workspace=WORKSPACE");
|
||||
CLI::taskOpt("lang", "Specify the language which will be used to rebuild the case cache list. If this option isn't included, then 'en' (English) will be used by default.", "lLANG","lang=LANG");
|
||||
CLI::taskOpt("port", "Specify the port number used by MySQL. If not specified, then the port 3306 will be used by default.", "pPORT");
|
||||
"w:", "workspace=");
|
||||
CLI::taskOpt("lang", "Specify the language which will be used to rebuild the case cache list. If this option isn't included, then 'en' (English) will be used by default.", "l:","lang=");
|
||||
CLI::taskOpt("port", "Specify the port number used by MySQL. If not specified, then the port 3306 will be used by default.", "p:");
|
||||
CLI::taskRun("run_workspace_restore");
|
||||
|
||||
CLI::taskName('cacheview-repair');
|
||||
@@ -93,7 +93,7 @@ CLI::taskDescription(<<<EOT
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace', true, true);
|
||||
CLI::taskOpt("lang", "Specify the language to rebuild the case cache list. If not specified, then 'en' (English) will be used by default.\n Ex: -lfr (French) Ex: --lang=zh-CN (Mainland Chinese)", "lLANG", "lang=LANG");
|
||||
CLI::taskOpt("lang", "Specify the language to rebuild the case cache list. If not specified, then 'en' (English) will be used by default.\n Ex: -lfr (French) Ex: --lang=zh-CN (Mainland Chinese)", "l:","lang=");
|
||||
CLI::taskRun("run_cacheview_upgrade");
|
||||
|
||||
CLI::taskName('database-upgrade');
|
||||
@@ -171,7 +171,7 @@ EOT
|
||||
);
|
||||
//CLI::taskArg('workspace', true);
|
||||
CLI::taskOpt("workspace", "Select the workspace whose case folders will be migrated, if multiple workspaces are present in the server.\n Ex: -wworkflow. Ex: --workspace=workflow",
|
||||
"wWORKSPACE", "workspace=WORKSPACE");
|
||||
"w:", "workspace=");
|
||||
CLI::taskRun("runStructureDirectories");
|
||||
|
||||
CLI::taskName("database-generate-self-service-by-value");
|
||||
|
||||
@@ -52,7 +52,7 @@ class multipleFilesBackup
|
||||
$metadata = $workspace->getMetadata();
|
||||
CLI::logging( "Creating temporary files on database...\n" );
|
||||
$metadata["databases"] = $workspace->exportDatabase( $tempDirectory );
|
||||
$metadata["directories"] = array ("{$workspace->name}.files");
|
||||
$metadata["directories"] = array ("{$workspace->name}");
|
||||
$metadata["version"] = 1;
|
||||
$metaFilename = "$tempDirectory/{$workspace->name}.meta";
|
||||
if (! file_put_contents( $metaFilename, str_replace( array (",","{","}"), array (",\n ","{\n ","\n}\n"), G::json_encode( $metadata ) ) )) {
|
||||
@@ -110,6 +110,8 @@ class multipleFilesBackup
|
||||
$DecommpressCommand .= " | tar xzv";
|
||||
|
||||
$tempDirectory = PATH_DATA . "upgrade/" . basename( tempnam( __FILE__, '' ) );
|
||||
$tempDirectoryHelp = $tempDirectory;
|
||||
|
||||
$parentDirectory = PATH_DATA . "upgrade";
|
||||
if (is_writable( $parentDirectory )) {
|
||||
mkdir( $tempDirectory );
|
||||
@@ -123,6 +125,9 @@ class multipleFilesBackup
|
||||
CLI::logging( "\nUncompressed into: " . $tempDirectory . "\n" );
|
||||
|
||||
//Search for metafiles in the new standard (the old standard would contain meta files.
|
||||
$decommpressedfile = scandir($tempDirectoryHelp.dirname($tempDirectoryHelp), 1);
|
||||
$tempDirectory = $tempDirectoryHelp.dirname($tempDirectoryHelp)."/".$decommpressedfile[0];
|
||||
|
||||
$metaFiles = glob( $tempDirectory . "/*.meta" );
|
||||
if (empty( $metaFiles )) {
|
||||
$metaFiles = glob( $tempDirectory . "/*.txt" );
|
||||
@@ -173,9 +178,12 @@ class multipleFilesBackup
|
||||
if (file_exists( $workspace->path )) {
|
||||
G::rm_dir( $workspace->path );
|
||||
}
|
||||
|
||||
$tempDirectorySite = $tempDirectoryHelp.dirname($workspace->path);
|
||||
|
||||
foreach ($metadata->directories as $dir) {
|
||||
CLI::logging( "+> Restoring directory '$dir'\n" );
|
||||
if (! rename( "$tempDirectory/$dir", $workspace->path )) {
|
||||
if (! rename( "$tempDirectorySite/$dir", $workspace->path )) {
|
||||
throw new Exception( "There was an error copying the backup files ($tempDirectory/$dir) to the workspace directory {$workspace->path}." );
|
||||
}
|
||||
}
|
||||
@@ -197,13 +205,20 @@ class multipleFilesBackup
|
||||
if (! $link) {
|
||||
throw new Exception( 'Could not connect to system database: ' . mysql_error() );
|
||||
}
|
||||
|
||||
if (strpos($metadata->DB_RBAC_NAME, 'rb_') === false) {
|
||||
$onedb = true;
|
||||
} else {
|
||||
$onedb = false;
|
||||
}
|
||||
|
||||
$newDBNames = $workspace->resetDBInfo( $dbHost, $createWorkspace );
|
||||
$newDBNames = $workspace->resetDBInfo( $dbHost, $createWorkspace, $onedb );
|
||||
$aParameters = array('dbHost'=>$dbHost,'dbUser'=>$dbUser,'dbPass'=>$dbPass);
|
||||
|
||||
foreach ($metadata->databases as $db) {
|
||||
$dbName = $newDBNames[$db->name];
|
||||
CLI::logging( "+> Restoring database {$db->name} to $dbName\n" );
|
||||
$workspace->executeSQLScript( $dbName, "$tempDirectory/{$db->name}.sql" );
|
||||
$workspace->executeSQLScript( $dbName, "$tempDirectory/{$db->name}.sql", $aParameters );
|
||||
$workspace->createDBUser( $dbName, $db->pass, "localhost", $dbName );
|
||||
$workspace->createDBUser( $dbName, $db->pass, "%", $dbName );
|
||||
}
|
||||
|
||||
@@ -1244,7 +1244,7 @@ class workspaceTools
|
||||
* @param string $hostname the hostname the user will be connecting from
|
||||
* @param string $database the database to grant permissions
|
||||
*/
|
||||
private function createDBUser($username, $password, $hostname, $database)
|
||||
public function createDBUser($username, $password, $hostname, $database)
|
||||
{
|
||||
mysql_select_db("mysql");
|
||||
$hostname = array_shift(explode(":", $hostname));
|
||||
@@ -1282,7 +1282,7 @@ class workspaceTools
|
||||
* @param string $filename the script filename
|
||||
* @param string $database the database to execute this script into
|
||||
*/
|
||||
private function executeSQLScript($database, $filename, $parameters)
|
||||
public function executeSQLScript($database, $filename, $parameters)
|
||||
{
|
||||
mysql_query("CREATE DATABASE IF NOT EXISTS " . mysql_real_escape_string($database));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user