Ejemplo n.º 1
0
 /**
  * Process generator
  *
  * @throws \phpbu\App\Exception
  */
 protected function createProcess()
 {
     // make sure there is a file to compress
     if (empty($this->fileToCompress)) {
         throw new Exception('file to compress not set');
     }
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmd->silence();
         // i kill you
     }
     // don't add '-f' option for 'zip' executable issue #34
     if ($this->cmd !== 'zip') {
         $cmd->addOptionIfNotEmpty('-f', $this->force, false);
     }
     $cmd->addArgument($this->fileToCompress);
     return $process;
 }
Ejemplo n.º 2
0
 /**
  * Subclass Process generator.
  *
  * @return \phpbu\App\Cli\Process
  * @throws \phpbu\App\Exception
  */
 protected function createProcess()
 {
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     if (!empty($this->args)) {
         $cmd->addOption($this->args);
     } else {
         if (empty($this->syncSource)) {
             throw new Exception('source to sync is missing');
         }
         if (empty($this->path)) {
             throw new Exception('target path is missing');
         }
         // Silence rsync output
         // std err > dev null
         //            $cmd->silence(); // TODO: re-enable
         // Additional options. Use archive mode, verbose and compress if not already done
         $options = '-av' . ($this->compressed ? 'z' : '');
         $cmd->addOption($options);
         // Exclude files
         if (count($this->excludes)) {
             foreach ($this->excludes as $ex) {
                 $cmd->addOption('--exclude', $ex);
             }
         }
         $cmd->addOptionIfNotEmpty('--delete', $this->delete, false);
         // Remote source
         // Specify a custom port
         if ($this->port && $this->port != 22) {
             $cmd->addOption('-e', 'ssh -p ' . $this->port);
         }
         // Build the source argument string
         $cmd->addArgument($this->user . '@' . $this->host . ':' . $this->syncSource);
         // Local target
         $cmd->addArgument($this->path);
     }
     return $process;
 }
Ejemplo n.º 3
0
 /**
  * Subclass Process generator.
  *
  * @return \phpbu\App\Cli\Executable
  * @throws \phpbu\App\Exception
  */
 public function createProcess()
 {
     if (empty($this->dumpDir)) {
         throw new Exception('dump dir is mandatory');
     }
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmd->silence();
         // i kill you
     }
     $cmd->addOptionIfNotEmpty('--server.username', $this->username, true, ' ');
     $cmd->addOptionIfNotEmpty('--server.password', $this->password, true, ' ');
     $cmd->addOptionIfNotEmpty('--server.endpoint', $this->endpoint, true, ' ');
     $cmd->addOptionIfNotEmpty('--server.database', $this->database, true, ' ');
     if (count($this->collections)) {
         foreach ($this->collections as $collection) {
             $cmd->addOption('--collection', $collection, ' ');
         }
     }
     if ($this->disableAuthentication) {
         $cmd->addOption('--server.disable-authentication', 'true', ' ');
     }
     if ($this->includeSystemCollections) {
         $cmd->addOption('--include-system-collections', 'true', ' ');
     }
     if ($this->dumpData) {
         $cmd->addOption('--dump-data', 'true', ' ');
     }
     $cmd->addOption('--output-directory', $this->dumpDir, ' ');
     return $process;
 }
Ejemplo n.º 4
0
 /**
  * Subclass Process generator.
  *
  * @return \phpbu\App\Cli\Process
  * @throws \phpbu\App\Exception
  */
 protected function createProcess()
 {
     if (empty($this->host)) {
         throw new Exception('host is mandatory');
     }
     if (empty($this->dumpPathname)) {
         throw new Exception('no file to dump to');
     }
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmd->silence();
         // i kill you
     }
     $cmd->addOption('--input', $this->generateNodeUrl($this->host, $this->user, $this->password, $this->index));
     $cmd->addOptionIfNotEmpty('--type', $this->type);
     $cmd->addOption('--output', $this->dumpPathname);
     return $process;
 }
Ejemplo n.º 5
0
 /**
  * Process generator
  */
 protected function createProcess()
 {
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmd->silence();
         // i kill you
     }
     $cmd->addOptionIfNotEmpty('--user', $this->user);
     $cmd->addOptionIfNotEmpty('--password', $this->password);
     $cmd->addOptionIfNotEmpty('--host', $this->host);
     $cmd->addOptionIfNotEmpty($this->extraCommand, $this->extraCommand, false);
     $cmd->addOptionIfNotEmpty('-q', $this->quick, false);
     $cmd->addOptionIfNotEmpty('-C', $this->compress, false);
     $cmd->addOptionIfNotEmpty('-e', $this->extendedInsert, false);
     $cmd->addOptionIfNotEmpty('--hex-blob', $this->hexBlob, false);
     if (count($this->tablesToDump)) {
         $cmd->addOption('--tables', $this->tablesToDump);
     } else {
         if (count($this->databasesToDump)) {
             $cmd->addOption('--databases', $this->databasesToDump);
         } else {
             $cmd->addOption('--all-databases');
         }
     }
     if (count($this->tablesToIgnore)) {
         foreach ($this->tablesToIgnore as $table) {
             $cmd->addOption('--ignore-table', $table);
         }
     }
     if ($this->noData) {
         $cmd->addOption('--no-data');
     } else {
         if (count($this->structureOnly)) {
             $cmd2 = clone $cmd;
             foreach ($this->structureOnly as $table) {
                 $cmd2->addOption('--ignore-table', $table);
             }
             $cmd2->addOption('--skip-add-drop-table');
             $cmd2->addOption('--no-create-db');
             $cmd2->addOption('--no-create-info');
             $cmd->addOption('--no-data');
             $process->addCommand($cmd2);
         }
     }
     $process->redirectOutputTo($this->dumpPathname);
     return $process;
 }
Ejemplo n.º 6
0
 /**
  * Subclass Process generator.
  *
  * @return \phpbu\App\Cli\Process
  * @throws \phpbu\App\Exception
  */
 protected function createProcess()
 {
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     if (!empty($this->args)) {
         $cmd->addOption($this->args);
     } else {
         if (empty($this->syncSource)) {
             throw new Exception('source to sync is missing');
         }
         if (empty($this->path)) {
             throw new Exception('target path is missing');
         }
         // std err > dev null
         $cmd->silence();
         // use archive mode, verbose and compress if not already done
         $options = '-av' . ($this->compressed ? 'z' : '');
         $cmd->addOption($options);
         if (count($this->excludes)) {
             foreach ($this->excludes as $ex) {
                 $cmd->addOption('--exclude', $ex);
             }
         }
         $cmd->addOptionIfNotEmpty('--delete', $this->delete, false);
         $cmd->addArgument($this->syncSource);
         // target handling
         // get rsync host string
         $syncTarget = $this->getRsyncHostString();
         // remote path
         $syncTarget .= $this->path;
         $cmd->addArgument($syncTarget);
     }
     return $process;
 }
Ejemplo n.º 7
0
 /**
  * Add the 'rm' command to remove the uncrypted file.
  *
  * @param \phpbu\App\Cli\Process $process
  */
 protected function addDeleteCommand(Process $process)
 {
     if ($this->deleteUncrypted) {
         $cmd = new Cmd('rm');
         if (!$this->showStdErr) {
             $cmd->silence();
             // i kill you
         }
         $cmd->addArgument($this->sourceFile);
         $process->addCommand($cmd);
     }
 }
Ejemplo n.º 8
0
 /**
  * RedisCli Process generator.
  *
  * @return \phpbu\App\Cli\Process
  * @throws \phpbu\App\Exception
  */
 protected function createProcess()
 {
     if (empty($this->command)) {
         throw new Exception('Choose command to execute');
     }
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmd->silence();
     }
     $this->setOptions($cmd);
     $cmd->addOption($this->command);
     return $process;
 }
Ejemplo n.º 9
0
 /**
  * Process generator
  */
 protected function createProcess()
 {
     // check source and target settings
     if (empty($this->path)) {
         throw new Exception('no directory to compress');
     }
     if (empty($this->tarPathname)) {
         throw new Exception('no target filename set');
     }
     $process = new Process();
     $tar = new Cmd($this->binary);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $tar->silence();
         // i kill you
     }
     $tar->addOption('-' . $this->compression . 'cf');
     $tar->addArgument($this->tarPathname);
     $tar->addOption('-C', $this->path, ' ');
     $tar->addArgument('.');
     $process->addCommand($tar);
     // delete the source data if requested
     if ($this->removeSourceDir) {
         $process->addCommand($this->getRmCommand());
     }
     return $process;
 }
Ejemplo n.º 10
0
 /**
  * Subclass Process generator.
  *
  * @return \phpbu\App\Cli\Process
  * @throws \phpbu\App\Exception
  */
 public function createProcess()
 {
     if (empty($this->dumpDir)) {
         throw new Exception('no directory to dump to');
     }
     $process = new Process();
     $cmdDump = new Cmd($this->binary);
     $cmdApply = new Cmd($this->binary);
     $process->addCommand($cmdDump);
     $process->addCommand($cmdApply);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmdDump->silence();
         $cmdApply->silence();
         // i kill you
     }
     $cmdDump->addOption('--no-timestamp');
     $cmdDump->addOptionIfNotEmpty('--datadir', $this->dataDir);
     $cmdDump->addOptionIfNotEmpty('--user', $this->user);
     $cmdDump->addOptionIfNotEmpty('--password', $this->password);
     $cmdDump->addOptionIfNotEmpty('--host', $this->host);
     if (!empty($this->include)) {
         $cmdDump->addOption('--include', $this->include);
     } else {
         if (count($this->databases)) {
             $cmdDump->addOption('--databases', implode(' ', $this->databases));
         }
     }
     $cmdDump->addArgument($this->dumpDir);
     $cmdApply->addOption('--apply-log');
     $cmdApply->addArgument($this->dumpDir);
     return $process;
 }
Ejemplo n.º 11
0
 /**
  * Subclass Process generator.
  *
  * @return \phpbu\App\Cli\Process
  * @throws \phpbu\App\Exception
  */
 protected function createProcess()
 {
     if (empty($this->targetFile)) {
         throw new Exception('target file is missing');
     }
     if (empty($this->key) && empty($this->keyFile)) {
         throw new Exception('one of \'key\' or \'keyFile\' is mandatory');
     }
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmd->silence();
         // i kill you
     }
     $cmd->addOptionIfNotEmpty('-u', $this->deleteUncrypted, false);
     $cmd->addOptionIfNotEmpty('-k', $this->key, true, ' ');
     $cmd->addOptionIfNotEmpty('-f', $this->keyFile, true, ' ');
     $cmd->addOptionIfNotEmpty('-h', $this->hash, true, ' ');
     $cmd->addOptionIfNotEmpty('-a', $this->algorithm, true, ' ');
     $cmd->addOptionIfNotEmpty('-c', $this->config, true, ' ');
     $cmd->addArgument($this->targetFile);
     return $process;
 }
Ejemplo n.º 12
0
 /**
  * Subclass Process generator.
  *
  * @return \phpbu\App\Cli\Process
  * @throws \phpbu\App\Exception
  */
 protected function createProcess()
 {
     if (empty($this->dumpDir)) {
         throw new Exception('no directory to dump to');
     }
     $process = new Process();
     $cmd = new Cmd($this->binary);
     $process->addCommand($cmd);
     // no std error unless it is activated
     if (!$this->showStdErr) {
         $cmd->silence();
         // i kill you
     }
     $cmd->addOption('--out', $this->dumpDir, ' ');
     $cmd->addOptionIfNotEmpty('--ipv6', $this->useIPv6, false);
     $cmd->addOptionIfNotEmpty('--host', $this->host, true, ' ');
     $cmd->addOptionIfNotEmpty('--user', $this->user, true, ' ');
     $cmd->addOptionIfNotEmpty('--password', $this->password, true, ' ');
     $cmd->addOptionIfNotEmpty('--authenticationDatabase', $this->authenticationDatabase, true, ' ');
     if (count($this->databases)) {
         foreach ($this->databases as $db) {
             $cmd->addOption('--database', $db, ' ');
         }
     }
     if (count($this->collections)) {
         foreach ($this->collections as $col) {
             $cmd->addOption('--collection', $col, ' ');
         }
     }
     $cmd->addOptionIfNotEmpty('--excludeCollection', $this->excludeCollections);
     $cmd->addOptionIfNotEmpty('--excludeCollectionWithPrefix', $this->excludeCollectionsWithPrefix);
     return $process;
 }