/** * 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); }
/** * (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; }
/** * 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); }