diff --git a/datamodels/2.x/itop-backup/status.php b/datamodels/2.x/itop-backup/status.php index 5eead230d..d3bf6cef7 100644 --- a/datamodels/2.x/itop-backup/status.php +++ b/datamodels/2.x/itop-backup/status.php @@ -96,7 +96,7 @@ try { // $sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', ''); $sMySQLBinDir = utils::ReadParam('mysql_bindir', $sMySQLBinDir, true); - $sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump'); + $sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction()); $sCommand = "$sMySQLDump -V 2>&1"; $aOutput = []; diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php index f1609791b..4a89c3f24 100644 --- a/setup/backup.class.inc.php +++ b/setup/backup.class.inc.php @@ -346,7 +346,7 @@ class DBBackup $this->LogInfo("Starting backup of $this->sDBHost/$this->sDBName(suffix:'$this->sDBSubName')"); $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 $sTmpFileName = self::EscapeShellArg($sBackupFileName); @@ -603,6 +603,16 @@ EOF; return '"'.$sMySQLCommand.'"'; } + + public static function GetDumpFunction(): string + { + $version = CMDBSource::QueryToScalar('SELECT VERSION()'); + if (is_string($version) && stripos($version, 'MariaDB') !== false) { + return 'mariadb-dump'; + } + + return 'mysqldump'; + } } class TarGzArchive implements BackupArchive diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index d04c920df..c019dfe04 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -564,7 +564,7 @@ class SetupUtils $sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', ''); } try { - $sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump'); + $sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction()); } catch (Exception $e) { $aResult[] = new CheckResult(CheckResult::ERROR, $e->getMessage()); return $aResult;