/** * Returns the executable for this action. * * @param \phpbu\App\Backup\Target $target * @return \phpbu\App\Cli\Executable */ public function getExecutable(Target $target) { if (null === $this->executable) { $this->executable = new Tar($this->pathToCommand); $this->executable->archiveDirectory($this->path); $archiveName = Tar::isCompressorValid($target->getCompressor()->getCommand()) ? $target->getPathname() : $target->getPathnamePlain(); $this->executable->archiveTo($archiveName)->useCompression($target->getCompressor()->getCommand())->removeSourceDirectory(true); } return $this->executable; }
/** * Setup the Executable to run the 'tar' command. * * @param \phpbu\App\Backup\Target * @return \phpbu\App\Cli\Executable */ public function getExecutable(Target $target) { if (null == $this->executable) { // check if tar supports requested compression if ($target->shouldBeCompressed()) { if (!Executable\Tar::isCompressorValid($target->getCompressor()->getCommand())) { $this->pathToArchive = $target->getPathnamePlain(); } else { // compression could be handled by the tar command $this->pathToArchive = $target->getPathname(); $this->compression = $target->getCompressor()->getCommand(); } } else { // no compression at all $this->pathToArchive = $target->getPathname(); } $this->executable = new Executable\Tar($this->pathToTar); $this->executable->archiveDirectory($this->path)->useCompression($this->compression)->archiveTo($this->pathToArchive)->showStdErr($this->showStdErr); } return $this->executable; }
/** * If 'tar' can't compress with the requested compressor this will return false. * * @param \phpbu\App\Backup\Target $target * @return bool */ public function canCompress(Target $target) { return Tar::isCompressorValid($target->getCompressor()->getCommand()); }