/**
  * @return DatabaseBackupStrategyModel[]
  */
 public function collectDatabasesStrategies()
 {
     $fileLocator = new FileLocator(__DIR__ . '/../../../app/config');
     try {
         $fileStrategies = $fileLocator->locate('strategies.yml');
     } catch (InvalidArgumentException $ex) {
         /* No strategies file detected? No strategies then. :=) */
         return [];
     }
     $strategies = file_get_contents($fileStrategies);
     $config = Yaml::parse($strategies);
     $config = $config['easy_backups'];
     $processor = new Processor();
     $configuration = new DatabaseStrategyConfiguration();
     $validatedConfig = $processor->processConfiguration($configuration, [$config]);
     $strategies = [];
     if (isset($validatedConfig['strategies'])) {
         foreach ($validatedConfig['strategies'] as $strategyConfig) {
             $strategy = new DatabaseBackupStrategyModel($strategyConfig['identifier'], $strategyConfig['compressor_strategy'], $strategyConfig['saver_strategy'], $strategyConfig['dump_settings']['type'], new DatabaseSettings($strategyConfig['dump_settings']['options']['host'], $strategyConfig['dump_settings']['options']['user'], $strategyConfig['dump_settings']['options']['pass'], $strategyConfig['dump_settings']['options']['name'], $strategyConfig['dump_settings']['options']['port'], $strategyConfig['dump_settings']['options']['ignore_tables'], $strategyConfig['dump_settings']['options']['one_dump_per_table']));
             $strategy->setDescription($strategyConfig['description']);
             $strategies[] = $strategy;
         }
     }
     return $strategies;
 }
 /**
  * @param DatabaseBackupStrategyModel $databaseStrategyModel
  * @param \DateTime                   $fromDate
  * @param \DateTime                   $untilDate
  *
  * @return FileReportModel[]
  */
 public function getReport(DatabaseBackupStrategyModel $databaseStrategyModel, \DateTime $fromDate, \DateTime $untilDate)
 {
     $fileReader = $this->chainSaver->getSaver($databaseStrategyModel->getFileSaverStrategy());
     $filesFound = [];
     $date = clone $fromDate;
     while ($date->getTimestamp() <= $untilDate->getTimestamp()) {
         $filesPattern = $this->fileNameResolver->resolvePatternForDay($date, 'database', 'tar.xz');
         $filesPatternPath = new Path($filesPattern);
         $filesFound = array_merge($filesFound, $fileReader->listContents($filesPatternPath, clone $date->setTime(0, 0, 0), clone $date->setTime(23, 59, 59)));
         $date->add(new \DateInterval('PT86400S'));
     }
     return $filesFound;
 }
 /**
  * @param DatabaseBackupStrategyModel $configuration
  * @param callable                    $setActionName
  *
  * @throws UnableToProcessException
  *
  * @return File[]
  */
 public function dump(DatabaseBackupStrategyModel $configuration, callable $setActionName)
 {
     /* Dump the database */
     $setActionName('Dumping database...');
     $databaseDumper = $this->chainDatabasesDumper->getDumper($configuration->getDatabaseType());
     $dumpFiles = $databaseDumper->dump($configuration->getDatabaseSettings());
     /* Compress the database */
     $setActionName('Compressing database...');
     $compressor = $this->chainCompressor->getCompressor($configuration->getCompressorStrategy());
     $dumpCompressedFiles = $compressor->compress($dumpFiles);
     /* Save the files */
     $setActionName('Saving files...');
     $saver = $this->chainSaver->getSaver($configuration->getFileSaverStrategy());
     $savedFiles = $saver->save($dumpCompressedFiles);
     return $savedFiles;
 }