Example #1
0
function shutdownAction($actionId, $actionType, $filePath, $dbFilePath, $backupObj)
{
    if ($backupObj->getReloading()) {
        return;
    }
    $action = SGBackup::getAction($actionId);
    if ($action && ($action['status'] == SG_ACTION_STATUS_IN_PROGRESS_DB || $action['status'] == SG_ACTION_STATUS_IN_PROGRESS_FILES)) {
        SGBackupLog::writeExceptionObject(new SGExceptionServerError('Execution time abort'));
        SGBackup::changeActionStatus($actionId, SG_ACTION_STATUS_ERROR);
        if ($actionType == SG_ACTION_TYPE_BACKUP) {
            @unlink($filePath);
            @unlink($dbFilePath);
        }
    }
}
Example #2
0
 private function warn($message)
 {
     $this->warningsFound = true;
     SGBackupLog::writeWarning($message);
 }
Example #3
0
 private function resetBackupProgress()
 {
     $this->totalRowCount = 0;
     $this->currentRowCount = 0;
     $this->progressUpdateInterval = SGConfig::get('SG_ACTION_PROGRESS_UPDATE_INTERVAL');
     $tableNames = $this->getTables();
     foreach ($tableNames as $table) {
         $this->totalRowCount += $this->getTableRowsCount($table);
     }
     $this->nextProgressUpdate = $this->progressUpdateInterval;
     SGBackupLog::write('Total tables to backup: ' . count($tableNames));
     SGBackupLog::write('Total rows to backup: ' . $this->totalRowCount);
 }
Example #4
0
 private function resetBackupProgress()
 {
     $this->totalRowCount = 0;
     $this->currentRowCount = 0;
     $tableNames = $this->getTables();
     foreach ($tableNames as $table) {
         $this->totalRowCount += $this->getTableRowsCount($table);
     }
     $this->nextProgressUpdate = $this->progressUpdateInterval;
     SGBackupLog::write('Total tables to backup: ' . count($tableNames));
     SGBackupLog::write('Total rows to backup: ' . $this->totalRowCount);
 }
Example #5
0
 private function didFinishRestore()
 {
     $action = $this->didFindWarnings() ? SG_ACTION_STATUS_FINISHED_WARNINGS : SG_ACTION_STATUS_FINISHED;
     self::changeActionStatus($this->actionId, $action);
     SGBackupLog::writeAction('restore', SG_BACKUP_LOG_POS_END);
     if (SGBoot::isFeatureAvailable('NOTIFICATIONS')) {
         SGBackupMailNotification::sendRestoreNotification(true);
     }
     SGBackupLog::write('Total duration: ' . formattedDuration($this->actionStartTs, time()));
     $this->cleanUp();
 }
Example #6
0
 /**
  * Exports all the tables selected from database
  *
  * @return null
  */
 private function exportTables($data)
 {
     // Exporting tables one by one
     foreach ($this->tables as $table) {
         if (in_array($table, $this->dumpSettings['exclude-tables'], true)) {
             continue;
         }
         if (empty($data)) {
             SGBackupLog::writeAction('backup table: ' . $table, SG_BACKUP_LOG_POS_START);
         }
         $this->getTableStructure($table, !empty($data));
         if (false === $this->dumpSettings['no-data']) {
             $this->listValues($table, $data);
             $data = array();
         }
         SGBackupLog::writeAction('backup table: ' . $table, SG_BACKUP_LOG_POS_END);
         $this->excludeTables[] = $table;
     }
 }