Compare commits

...

3 Commits

Author SHA1 Message Date
Anne-Catherine
3c01bd2924 Update setup/backup.class.inc.php
Co-authored-by: Thomas Casteleyn <thomas.casteleyn@super-visions.com>
2026-03-02 15:53:37 +01:00
Anne-Cath
7f24bcedd8 N°7150 - Backup : on MariaDB >= 11.0.1 call mariadb-dump instead of mysqldump - fix setup 2026-02-27 17:24:31 +01:00
Anne-Cath
4ecf81d032 N°7150 - Backup : on MariaDB >= 11.0.1 call mariadb-dump instead of mysqldump 2026-02-27 16:36:18 +01:00
3 changed files with 16 additions and 3 deletions

View File

@@ -96,7 +96,7 @@ try {
// //
$sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', ''); $sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', '');
$sMySQLBinDir = utils::ReadParam('mysql_bindir', $sMySQLBinDir, true); $sMySQLBinDir = utils::ReadParam('mysql_bindir', $sMySQLBinDir, true);
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump'); $sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction());
$sCommand = "$sMySQLDump -V 2>&1"; $sCommand = "$sMySQLDump -V 2>&1";
$aOutput = []; $aOutput = [];

View File

@@ -346,7 +346,7 @@ class DBBackup
$this->LogInfo("Starting backup of $this->sDBHost/$this->sDBName(suffix:'$this->sDBSubName')"); $this->LogInfo("Starting backup of $this->sDBHost/$this->sDBName(suffix:'$this->sDBSubName')");
$sMySQLBinDir = utils::ReadParam('mysql_bindir', $this->sMySQLBinDir, true); $sMySQLBinDir = utils::ReadParam('mysql_bindir', $this->sMySQLBinDir, true);
$sMySQLDump = $this->MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump'); $sMySQLDump = $this->MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction());
// Store the results in a temporary file // Store the results in a temporary file
$sTmpFileName = self::EscapeShellArg($sBackupFileName); $sTmpFileName = self::EscapeShellArg($sBackupFileName);
@@ -603,6 +603,16 @@ EOF;
return '"'.$sMySQLCommand.'"'; return '"'.$sMySQLCommand.'"';
} }
public static function GetDumpFunction(): string
{
$sVersion = CMDBSource::GetDBVersion();
if (stripos($sVersion, 'MariaDB') !== false) {
return 'mariadb-dump';
}
return 'mysqldump';
}
} }
class TarGzArchive implements BackupArchive class TarGzArchive implements BackupArchive

View File

@@ -559,12 +559,15 @@ class SetupUtils
$aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server"); $aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server");
} }
MetaModel::LoadConfig(utils::GetConfig());
// availability of mysqldump // availability of mysqldump
if (empty($sMySQLBinDir) && null != MetaModel::GetConfig()) { if (empty($sMySQLBinDir) && null != MetaModel::GetConfig()) {
$sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', ''); $sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', '');
} }
try { try {
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump'); $oConfig = MetaModel::GetConfig();
CMDBSource::InitFromConfig($oConfig);
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction());
} catch (Exception $e) { } catch (Exception $e) {
$aResult[] = new CheckResult(CheckResult::ERROR, $e->getMessage()); $aResult[] = new CheckResult(CheckResult::ERROR, $e->getMessage());
return $aResult; return $aResult;