Skip to content

Commit 4ecf81d

Browse files
committed
N°7150 - Backup : on MariaDB >= 11.0.1 call mariadb-dump instead of mysqldump
1 parent fc967c0 commit 4ecf81d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

datamodels/2.x/itop-backup/status.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function GenerateBackupsList(string $sListTitleDictKey, string $sNoRecordDictKey
9696
//
9797
$sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', '');
9898
$sMySQLBinDir = utils::ReadParam('mysql_bindir', $sMySQLBinDir, true);
99-
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump');
99+
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction());
100100
$sCommand = "$sMySQLDump -V 2>&1";
101101

102102
$aOutput = [];

setup/backup.class.inc.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function DoBackup($sBackupFileName)
346346
$this->LogInfo("Starting backup of $this->sDBHost/$this->sDBName(suffix:'$this->sDBSubName')");
347347
$sMySQLBinDir = utils::ReadParam('mysql_bindir', $this->sMySQLBinDir, true);
348348

349-
$sMySQLDump = $this->MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump');
349+
$sMySQLDump = $this->MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction());
350350

351351
// Store the results in a temporary file
352352
$sTmpFileName = self::EscapeShellArg($sBackupFileName);
@@ -603,6 +603,16 @@ public static function MakeSafeMySQLCommand($sMySQLBinDir, string $sCmd)
603603

604604
return '"'.$sMySQLCommand.'"';
605605
}
606+
607+
public static function GetDumpFunction(): string
608+
{
609+
$version = CMDBSource::QueryToScalar('SELECT VERSION()');
610+
if (is_string($version) && stripos($version, 'MariaDB') !== false) {
611+
return 'mariadb-dump';
612+
}
613+
614+
return 'mysqldump';
615+
}
606616
}
607617

608618
class TarGzArchive implements BackupArchive

setup/setuputils.class.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ public static function CheckBackupPrerequisites($sDBBackupPath, $sMySQLBinDir =
564564
$sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', '');
565565
}
566566
try {
567-
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump');
567+
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction());
568568
} catch (Exception $e) {
569569
$aResult[] = new CheckResult(CheckResult::ERROR, $e->getMessage());
570570
return $aResult;

0 commit comments

Comments
 (0)