public function processBackup(Form $form, $values)
 {
     $this->onBeforeManualBackup();
     try {
         $removeBackupAtTheEnd = true;
         $results = $this->databaseBackup->backup('manual', $removeBackupAtTheEnd);
         $errorOccurred = false;
         /** @var ResultObject $result */
         foreach ($results as $result) {
             if (!$result->hasNoErrors()) {
                 foreach ($result->getAllErrors() as $error) {
                     $this->presenter->flashMessage($error['message'], $error['type']);
                 }
                 $errorOccurred = true;
             }
         }
         if ($removeBackupAtTheEnd === false or $errorOccurred === false) {
             $this->presenter->flashMessage('Při zálohování nenastala žádná chyba.', 'success');
         }
     } catch (\Exception $e) {
         $this->logger->addError(sprintf('Manual database backup failure. %s', $e));
         $this->presenter->flashMessage('Databázi se nepodařilo zazálohovat. Zkontrolujte logy.', 'error');
     }
     $this->redirect('this');
 }
 public function handleBackup($pass)
 {
     if ($this->backupPassword !== null) {
         if ($this->backupPassword != $pass) {
             $this->logger->addWarning('Unauthorized try to backup database (auto)');
             return;
         }
     }
     if ($this->cache->load('databaseBackup') !== null) {
         $this->logger->addNotice('Another try to backup database (auto)');
         return;
     }
     try {
         $this->databaseBackup->backup('auto', true);
         $this->cache->save('databaseBackup', 'done', [Cache::EXPIRE => '23 hours']);
     } catch (\Exception $e) {
         $this->logger->addError(sprintf('Database backup failure (auto). %s', $e));
     }
 }