$sOperation = utils::ReadParam('operation', ''); switch ($sOperation) { case 'backup': require_once APPROOT . '/application/startup.inc.php'; require_once APPROOT . '/application/loginwebpage.class.inc.php'; LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin) $oPage = new ajax_page(""); $oPage->no_cache(); $oPage->SetContentType('text/html'); if (utils::GetConfig()->Get('demo_mode')) { $oPage->add("<div data-error-stimulus=\"Error\">Sorry, iTop is in <b>demonstration mode</b>: the feature is disabled.</div>"); } else { try { set_time_limit(0); $oBB = new BackupExec(APPROOT . 'data/backups/manual/', 0); $sRes = $oBB->Process(time() + 36000); // 10 hours to complete should be sufficient! } catch (Exception $e) { $oPage->p('Error: ' . $e->getMessage()); } } $oPage->output(); break; case 'restore_get_token': require_once APPROOT . '/application/startup.inc.php'; require_once APPROOT . '/application/loginwebpage.class.inc.php'; LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin) $oPage = new ajax_page(""); $oPage->no_cache();
// $oBackupMutex = new iTopMutex('backup.' . utils::GetCurrentEnvironment()); if ($oBackupMutex->TryLock()) { $oBackupMutex->Unlock(); } else { $oP->p(Dict::S('bkp-backup-running')); } $oRestoreMutex = new iTopMutex('restore.' . utils::GetCurrentEnvironment()); if ($oRestoreMutex->TryLock()) { $oRestoreMutex->Unlock(); } else { $oP->p(Dict::S('bkp-restore-running')); } // Do backup now // $oBackupExec = new BackupExec(); $oNext = $oBackupExec->GetNextOccurrence(); $oP->p(Dict::Format('bkp-next-backup', $aWeekDayToString[$oNext->Format('N')], $oNext->Format('Y-m-d'), $oNext->Format('H:i'))); $oP->p('<button onclick="LaunchBackupNow();">' . Dict::S('bkp-button-backup-now') . '</button>'); $oP->add('<div id="backup_success" class="header_message message_ok" style="display: none;"></div>'); $oP->add('<div id="backup_errors" class="header_message message_error" style="display: none;"></div>'); $oP->add('<input type="hidden" name="restore_token" id="restore_token"/>'); $sConfirmBackup = addslashes(Dict::S('bkp-confirm-backup')); $sPleaseWaitBackup = addslashes(Dict::S('bkp-wait-backup')); $sPleaseWaitRestore = addslashes(Dict::S('bkp-wait-restore')); $sRestoreDone = addslashes(Dict::S('bkp-success-restore')); $sMySQLBinDir = addslashes(MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', '')); $sDBHost = addslashes(MetaModel::GetConfig()->GetDBHost()); $sDBUser = addslashes(MetaModel::GetConfig()->GetDBUser()); $sDBPwd = addslashes(MetaModel::GetConfig()->GetDBPwd()); $sDBName = addslashes(MetaModel::GetConfig()->GetDBName());