Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datamodels/2.x/itop-backup/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function GenerateBackupsList(string $sListTitleDictKey, string $sNoRecordDictKey
//
$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 = [];
Expand Down
12 changes: 11 additions & 1 deletion setup/backup.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function DoBackup($sBackupFileName)
$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);
Expand Down Expand Up @@ -603,6 +603,16 @@ public static function MakeSafeMySQLCommand($sMySQLBinDir, string $sCmd)

return '"'.$sMySQLCommand.'"';
}

public static function GetDumpFunction(): string
{
$sVersion = CMDBSource::GetDBVersion();
if (stripos($sVersion, 'MariaDB') !== false) {
return 'mariadb-dump';
}

return 'mysqldump';
}
}

class TarGzArchive implements BackupArchive
Expand Down
5 changes: 4 additions & 1 deletion setup/setuputils.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,15 @@ public static function CheckBackupPrerequisites($sDBBackupPath, $sMySQLBinDir =
$aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server");
}

MetaModel::LoadConfig(utils::GetConfig());
// availability of mysqldump
if (empty($sMySQLBinDir) && null != MetaModel::GetConfig()) {
$sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', '');
}
try {
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, 'mysqldump');
$oConfig = MetaModel::GetConfig();
CMDBSource::InitFromConfig($oConfig);
$sMySQLDump = DBBackup::MakeSafeMySQLCommand($sMySQLBinDir, DBBackup::GetDumpFunction());
} catch (Exception $e) {
$aResult[] = new CheckResult(CheckResult::ERROR, $e->getMessage());
return $aResult;
Expand Down