コード例 #1
0
ファイル: Redis.php プロジェクト: imjerrybao/phpbu
 /**
  * Execute the backup.
  *
  * @see    \phpbu\App\Backup\Source
  * @param  \phpbu\App\Backup\Target $target
  * @param  \phpbu\App\Result        $result
  * @return \phpbu\App\Backup\Source\Status
  * @throws \phpbu\App\Exception
  */
 public function backup(Target $target, Result $result)
 {
     // set uncompressed default MIME type
     $target->setMimeType('application/octet-stream');
     $redisSave = $this->getExecutable($target);
     $redisLast = $this->getRedisLastSave($redisSave);
     $lastBackupTimestamp = $this->getLastBackupTime($redisLast);
     $saveResult = $redisSave->run();
     $result->debug($saveResult->getCmd());
     if (!$saveResult->wasSuccessful()) {
         throw new Exception('redis-cli BGSAVE failed');
     }
     $this->isDumpCreatedYet($lastBackupTimestamp, $redisLast);
     $pathToDump = $this->copyDumpToTargetDir($target);
     return Status::create()->uncompressed($pathToDump);
 }
コード例 #2
0
ファイル: Tar.php プロジェクト: imjerrybao/phpbu
 /**
  * (non-PHPDoc)
  *
  * @see    \phpbu\App\Backup\Source
  * @param  \phpbu\App\Backup\Target $target
  * @param  \phpbu\App\Result        $result
  * @return \phpbu\App\Backup\Source\Status
  * @throws \phpbu\App\Exception
  */
 public function backup(Target $target, Result $result)
 {
     // set uncompressed default MIME type
     $target->setMimeType('application/x-tar');
     $status = Status::create();
     $tar = $this->execute($target);
     // if tar doesn't handle the compression mark status uncompressed so the app can take care of compression
     if (!$this->executable->handlesCompression()) {
         $status->uncompressed($target->getPathnamePlain());
     }
     $result->debug($tar->getCmd());
     if (!$tar->wasSuccessful()) {
         throw new Exception('tar failed');
     }
     return $status;
 }
コード例 #3
0
ファイル: Directory.php プロジェクト: imjerrybao/phpbu
 /**
  * Compress the configured directory.
  *
  * @param  \phpbu\App\Backup\Target $target
  * @param  \phpbu\App\Result        $result
  * @return string
  * @throws \phpbu\App\Exception
  */
 public function compress(Target $target, Result $result)
 {
     $target->setMimeType('application/x-tar');
     return parent::compress($target, $result);
 }