mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
N°4227 - Manual iTop restore - protect any restore from cron or db updates and release readonly mode afterward only if restore set it itself
This commit is contained in:
@@ -133,7 +133,11 @@ class DBRestore extends DBBackup
|
||||
|
||||
try {
|
||||
IssueLog::Info('Backup Restore - LOCK acquired, executing...');
|
||||
$bReadonlyBefore = SetupUtils::IsInReadOnlyMode();
|
||||
SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
|
||||
|
||||
try {
|
||||
//safe zone for db backup => cron is stopped/ itop in readonly
|
||||
$this->LogInfo("Starting restore of ".basename($sFile));
|
||||
|
||||
|
||||
@@ -193,6 +197,14 @@ class DBRestore extends DBBackup
|
||||
|
||||
$oEnvironment = new RunTimeEnvironment($sEnvironment);
|
||||
$oEnvironment->CompileFrom($sEnvironment);
|
||||
} finally {
|
||||
if (! $bReadonlyBefore) {
|
||||
SetupUtils::ExitReadOnlyMode();
|
||||
} else {
|
||||
//we are in the scope of main process that needs to handle/keep readonly mode.
|
||||
$this->LogInfo("Keep readonly mode after restore");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -201,12 +201,7 @@ if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
else
|
||||
{
|
||||
$sEnvironment = utils::ReadParam('environment', 'production', false, 'raw_data');
|
||||
SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
|
||||
try{
|
||||
$oRestore->RestoreFromCompressedBackup($sBackupFile, $sEnvironment);
|
||||
} finally {
|
||||
SetupUtils::ExitReadOnlyMode();
|
||||
}
|
||||
}
|
||||
|
||||
$oP->output();
|
||||
|
||||
@@ -174,9 +174,8 @@ class DBBackup
|
||||
{
|
||||
$bReadonlyBefore = SetupUtils::IsInReadOnlyMode();
|
||||
SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
|
||||
|
||||
//safe zone for db backup => cron is stopped/ itop in readonly
|
||||
try {
|
||||
//safe zone for db backup => cron is stopped/ itop in readonly
|
||||
$bIsCmdbSourceInitialized = CMDBSource::GetMysqli() instanceof mysqli;
|
||||
if (!$bIsCmdbSourceInitialized) {
|
||||
$sErrorMsg = 'Cannot backup : CMDBSource not initialized !';
|
||||
@@ -209,7 +208,6 @@ class DBBackup
|
||||
//we are in the scope of main process that needs to handle/keep readonly mode (setup for example).
|
||||
$this->LogInfo("Keep readonly mode after backup");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user