Exemple #1
0
 public function reload(CM_OutputStream_Interface $output)
 {
     $scriptList = $this->_getScriptList();
     foreach ($scriptList as $setupScript) {
         if ($setupScript->shouldBeLoaded()) {
             $output->writeln('  Loading ' . $setupScript->getName() . '…');
             $setupScript->load($output);
         } elseif ($setupScript instanceof CM_Provision_Script_UnloadableInterface) {
             /** @var $setupScript CM_Provision_Script_Abstract */
             $output->writeln('  Reloading ' . $setupScript->getName() . '…');
             $setupScript->reload($output);
         }
     }
 }
 /**
  * @param CM_OutputStream_Interface $output
  * @param CM_File_Filesystem        $backupFilesystem
  */
 public function verifyExport(CM_OutputStream_Interface $output, CM_File_Filesystem $backupFilesystem)
 {
     $asserter = new S3Export_Asserter();
     $sourceFilesystem = $this->_getFilesystemOriginal();
     $filePaths = $this->_getRandomFiles($backupFilesystem, 100, 100000);
     foreach ($filePaths as $path) {
         $backupFile = new CM_File($path, $backupFilesystem);
         $sourceFile = new CM_File($path, $sourceFilesystem);
         $asserter->assertThat($sourceFile->exists(), function () use($output) {
             $output->write(".");
         }, function () use($output, $backupFile) {
             $output->writeln('E');
             $output->writeln("Integrity mismatch: Corresponding backup file does not exist for {$backupFile->getPath()}");
         });
         if ($sourceFile->exists()) {
             $asserter->assertThat($sourceFile->getHash() === $backupFile->getHash(), function () use($output) {
                 $output->write('.');
             }, function () use($output, $backupFile) {
                 $output->writeln('E');
                 $output->writeln("Integrity mismatch: Different hashes for {$backupFile->getPath()}");
             });
         }
     }
     $output->writeln('');
     $output->writeln(join(', ', ["Assertions run: {$asserter->getAssertionCount()}", "succeeded: {$asserter->getAssertionSuccessCount()}", "failed: {$asserter->getAssertionFailCount()}"]));
 }
Exemple #3
0
 /**
  * @param string   $key
  * @param DateTime $date
  */
 public function restoreByDeletingNewerVersions($key, DateTime $date)
 {
     $versions = $this->getVersions($key);
     $versionsToDelete = Functional\select($versions, function (CMService_AwsS3Versioning_Response_Version $version) use($key, $date) {
         $isExactKeyMatch = $key === $version->getKey();
         $isModifiedAfter = $date < $version->getLastModified();
         return $isExactKeyMatch && $isModifiedAfter;
     });
     $this->_streamOutput->writeln('Restoring `' . $key . '` - deleting ' . count($versionsToDelete) . ' versions...');
     if (count($versionsToDelete) > 0) {
         $objectsData = Functional\map($versionsToDelete, function (CMService_AwsS3Versioning_Response_Version $version) {
             return array('Key' => $version->getKey(), 'VersionId' => $version->getId());
         });
         $this->_client->deleteObjects(array('Bucket' => $this->_bucket, 'Objects' => $objectsData));
     }
 }
Exemple #4
0
 /**
  * @param string $action
  * @param string $path
  */
 public function notify($action, $path)
 {
     $actionMessage = str_pad($action, 10, ' ', STR_PAD_LEFT);
     $this->_output->writeln($actionMessage . '  ' . preg_replace('#^/#', '', $path));
 }
Exemple #5
0
 /**
  * @param CM_Log_Record $record
  */
 protected function _writeRecord(CM_Log_Record $record)
 {
     $this->_stream->writeln($this->_formatter->render($record));
 }