N°1173 : mysqldump now correctly use 'mysql_bindir' parameter on setup & move to prod's backups

SVN:trunk[5767]
This commit is contained in:
Stephen Abello
2018-05-03 15:00:13 +00:00
parent b43063a6d2
commit cb2c172483
5 changed files with 41 additions and 11 deletions

View File

@@ -20,7 +20,7 @@
define('ITOP_APPLICATION', 'iTop');
define('ITOP_APPLICATION_SHORT', 'iTop');
define('ITOP_VERSION', '2.5.0-beta');
define('ITOP_REVISION', 'svn');
define('ITOP_REVISION', '3804');
define('ITOP_BUILD_DATE', '$WCNOW$');
define('ACCESS_USER_WRITE', 1);
@@ -1176,9 +1176,19 @@ class Config
}
public function Get($sPropCode)
public function Get($sPropCode, $sModule = null)
{
return $this->m_aSettings[$sPropCode]['value'];
$sRetValue = '';
if(empty($sModule))
{
$sRetValue = $this->m_aSettings[$sPropCode]['value'];
}
else
{
$sRetValue = $this->m_aModuleSettings[$sModule][$sPropCode];
}
return $sRetValue;
}
/**

View File

@@ -40,7 +40,8 @@ class ApplicationInstaller
const ERROR = 2;
const WARNING = 3;
const INFO = 4;
/** @var \PHPParameters */
protected $oParams;
protected static $bMetaModelStarted = false;
@@ -180,8 +181,8 @@ class ApplicationInstaller
$aDBParams = $this->GetParamValues($this->oParams);
$oTempConfig = new Config();
$oTempConfig->UpdateFromParams($aDBParams);
self::DoBackup($oTempConfig, $sDestination, $sSourceConfigFile);
$sMySQLBinDir = $this->oParams->Get('mysql_bindir', null);
self::DoBackup($oTempConfig, $sDestination, $sSourceConfigFile, $sMySQLBinDir);
$aResult = array(
'status' => self::OK,
@@ -428,10 +429,14 @@ class ApplicationInstaller
*
* @since 2.5 uses a {@link Config} object to store DB parameters
*/
protected static function DoBackup($oConfig, $sBackupFileFormat, $sSourceConfigFile)
protected static function DoBackup($oConfig, $sBackupFileFormat, $sSourceConfigFile, $sMySQLBinDir = null)
{
$oBackup = new SetupDBBackup($oConfig);
$sTargetFile = $oBackup->MakeName($sBackupFileFormat);
if (!empty($sMySQLBinDir))
{
$oBackup->SetMySQLBinDir($sMySQLBinDir);
}
$oBackup->CreateCompressedBackup($sTargetFile, $sSourceConfigFile);
}

View File

@@ -677,6 +677,7 @@ if (class_exists('ZipArchive')) // The setup must be able to start even if the "
*
* @uses mysqldump -V Sample return value : mysqldump Ver 10.13 Distrib 5.7.19, for Win64 (x86_64)
* @since 2.5 needed to check compatibility with utf8mb4 (N°1001)
* @throws \BackupException
*/
private static function GetMysqldumpVersion($sMysqldumpCommand)
{
@@ -684,6 +685,11 @@ if (class_exists('ZipArchive')) // The setup must be able to start even if the "
$aOutput = array();
exec($sCommand, $aOutput, $iRetCode);
if ($iRetCode != 0)
{
throw new BackupException("mysqldump could not be executed (retcode=$iRetCode): Please make sure it is installed and located at : $sMysqldumpCommand");
}
$sMysqldumpOutput = $aOutput[0];
$aDumpVersionMatchResults = array();
preg_match('/Distrib (\d+\.\d+\.\d+)/', $sMysqldumpOutput, $aDumpVersionMatchResults);

View File

@@ -417,7 +417,7 @@ class SetupUtils
* @return array An array of CheckResults objects
* @internal param Page $oP The page used only for its 'log' method
*/
static function CheckBackupPrerequisites($sDestDir)
static function CheckBackupPrerequisites($sDestDir, $sMySQLBinDir = null)
{
$aResult = array();
SetupPage::log('Info - CheckBackupPrerequisites');
@@ -445,7 +445,11 @@ class SetupUtils
}
// availability of mysqldump
$sMySQLBinDir = utils::ReadParam('mysql_bindir', '', true);
if (empty($sMySQLBinDir) && null != MetaModel::GetConfig())
{
$sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', '');
}
if (empty($sMySQLBinDir))
{
$sMySQLDump = 'mysqldump';
@@ -472,7 +476,7 @@ class SetupUtils
else
{
// Unfortunately $aOutput is not really usable since we don't know its encoding (character set)
$aResult[] = new CheckResult(CheckResult::ERROR, "mysqldump could not be executed (retcode=$iRetCode): Please make sure it is installed and in the path");
$aResult[] = new CheckResult(CheckResult::ERROR, "mysqldump could not be executed (retcode=$iRetCode): Please make sure it is installed and " . (empty($sMySQLBinDir) ? "in the path" : "located at : $sMySQLDump"));
}
foreach($aOutput as $sLine)
{
@@ -833,6 +837,7 @@ class SetupUtils
'db_tls_enabled' => $oPrevConf->Get('db_tls.enabled'),
'db_tls_ca' => $oPrevConf->Get('db_tls.ca'),
'graphviz_path' => $oPrevConf->Get('graphviz_path'),
'mysql_bindir' => $oPrevConf->Get('mysql_bindir', 'itop-backup'),
);
}

View File

@@ -209,6 +209,7 @@ class WizStepInstallOrUpgrade extends WizardStep
$sDBBackupPath = $this->oWizard->GetParameter('db_backup_path', '');
$sTlsEnabled = $this->oWizard->GetParameter('db_tls_enabled', false);
$sTlsCA = $this->oWizard->GetParameter('db_tls_ca', '');
$sMySQLBinDir = $this->oWizard->GetParameter('mysql_bindir', null);
$sPreviousVersionDir = '';
if ($sInstallMode == '')
{
@@ -226,6 +227,8 @@ class WizStepInstallOrUpgrade extends WizardStep
$sTlsEnabled = $aPreviousInstance['db_tls_enabled'];
$sTlsCA = $aPreviousInstance['db_tls_ca'];
$this->oWizard->SaveParameter('graphviz_path', $aPreviousInstance['graphviz_path']);
$sMySQLBinDir = $aPreviousInstance['mysql_bindir'];
$this->oWizard->SaveParameter('mysql_bindir', $aPreviousInstance['mysql_bindir']);
$sPreviousVersionDir = APPROOT;
}
else
@@ -253,7 +256,7 @@ class WizStepInstallOrUpgrade extends WizardStep
SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix,
$sTlsEnabled, $sTlsCA, null);
$aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath);
$aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath, $sMySQLBinDir);
$bCanBackup = true;
$sMySQLDumpMessage = '';
foreach($aBackupChecks as $oCheck)
@@ -2343,6 +2346,7 @@ EOF
'sample_data' => ($this->oWizard->GetParameter('sample_data', '') == 'yes') ? true : false ,
'old_addon' => $this->oWizard->GetParameter('old_addon', false), // whether or not to use the "old" userrights profile addon
'options' => json_decode($this->oWizard->GetParameter('misc_options', '[]'), true),
'mysql_bindir' => $this->oWizard->GetParameter('mysql_bindir'),
);
if ($sBackupDestination != '')