コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
 /**
  * @param File[] $files
  *
  * @throws CanNotSavedException
  *
  * @return File[]
  */
 public function save($files)
 {
     $amazonAdapter = $this->getAdapter();
     $savedFiles = [];
     $i = 0;
     foreach ($files as $file) {
         $i++;
         $filePath = $this->fileNameResolver->resolve(new \DateTime('now', new \DateTimeZone('UTC')), 'database', $file->getExtension());
         $resource = fopen($file->getPath(), 'r');
         $amazonAnswer = $amazonAdapter->writeStream($filePath, $resource, new Config());
         fclose($resource);
         if ($amazonAnswer === false) {
             throw new CanNotSavedException();
         }
         $savedFiles[] = new File($amazonAnswer['path']);
     }
     return $savedFiles;
 }
コード例 #3
0
 /**
  * @param File[] $files
  *
  * @throws CanNotSavedException
  *
  * @return File[]
  */
 public function save($files)
 {
     $fileSystemAdapter = $this->getAdapter();
     $fileSystem = new Filesystem($fileSystemAdapter);
     $savedFiles = [];
     $i = 0;
     foreach ($files as $file) {
         $i++;
         $filePath = $this->fileNameResolver->resolve(new \DateTime('now', new \DateTimeZone('UTC')), 'database', $file->getExtension());
         $newBackupLocation = $this->backupFolder . '/' . $filePath;
         $currBackupLocation = $file->getPath();
         if ($fileSystem->has($newBackupLocation)) {
             $fileSystem->delete($newBackupLocation);
         }
         if (!$fileSystem->rename($currBackupLocation, $newBackupLocation)) {
             throw new CanNotSavedException();
         }
         $savedFiles[] = new File($fileSystemAdapter->applyPathPrefix($newBackupLocation));
     }
     return $savedFiles;
 }
コード例 #4
0
ファイル: FTPSaver.php プロジェクト: Viscaweb/EasyBackups
 /**
  * @param File[] $files
  *
  * @throws CanNotSavedException
  *
  * @return File[]
  */
 public function save($files)
 {
     $fileSystemAdapter = $this->getAdapter();
     $fileSystem = new Filesystem($fileSystemAdapter);
     $savedFiles = [];
     $i = 0;
     foreach ($files as $file) {
         $i++;
         $saveLocation = $this->fileNameResolver->resolve(new \DateTime('now', new \DateTimeZone('UTC')), 'database', $file->getExtension());
         if ($fileSystem->has($saveLocation)) {
             $fileSystem->delete($saveLocation);
         }
         $stream = fopen($file->getPath(), 'r+');
         $uploadFile = $fileSystem->writeStream($saveLocation, $stream);
         fclose($stream);
         if (!$uploadFile) {
             throw new CanNotSavedException();
         }
         $savedFiles[] = new File($fileSystemAdapter->applyPathPrefix($saveLocation));
     }
     return $savedFiles;
 }