protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('Exporting databases'); $io->section('Exporting all databases'); $strategies = $this->collectorDbStrategy->collectDatabasesStrategies(); $totalStrategies = count($strategies); $io->writeln($totalStrategies . ' strategie(s) found.'); $progressBar = new ProgressBar($output, $totalStrategies); $progressBar->setFormat(self::PROGRESS_BAR_FORMAT); $progressBar->setMessage('Beginning backuping'); $this->eventDispatcher->dispatch(Events::BACKUP_BEGINS, new BackupBeginsEvent($output)); $progressBar->start(); $reportContent = new \ArrayObject(); foreach ($strategies as $strategy) { $strategyIdentifier = $strategy->getIdentifier(); $setProgressBarMessage = function ($message) use($progressBar, $strategyIdentifier) { $message = "[{$strategyIdentifier}] {$message}"; $progressBar->setMessage($message); $progressBar->display(); }; $exportedFiles = $this->processorDatabaseDumper->dump($strategy, $setProgressBarMessage); $reportContent->append("Backuping of the database: {$strategyIdentifier}"); foreach ($exportedFiles as $file) { $filename = $file->getPath(); $reportContent->append("\t→ {$filename}"); } $progressBar->advance(); } $progressBar->finish(); $io->newLine(2); $io->section('Report'); $io->text($reportContent->getArrayCopy()); $this->eventDispatcher->dispatch(Events::BACKUP_ENDS, new BackupEndsEvent($output)); }
/** * @param Request $request * @param string $strategyIdentifier * @param string $requestedFromDate * @param string $requestedUntilDate * * @return JsonResponse */ public function testAction(Request $request, $strategyIdentifier, $requestedFromDate, $requestedUntilDate) { $fromDate = $this->createDateObject($requestedFromDate); $untilDate = $this->createDateObject($requestedUntilDate); $strategy = $this->backupStrategiesCollector->getStrategy($strategyIdentifier); $backupsFound = $this->dbMonitoringReport->getReport($strategy, $fromDate, $untilDate); return new JsonResponse($this->fileReportSerializer->serializeMany($backupsFound)); }