@@ -36,6 +36,21 @@ class Pgdump extends Abstraction implements Executable
3636 * @var int
3737 */
3838 private $ port ;
39+
40+ /**
41+ * Run the dump in parallel by dumping njobs tables simultaneously.
42+ * --jobs=njobs
43+ * @var int
44+ */
45+ private $ jobs ;
46+
47+ /**
48+ * Set SSL mode
49+ * PGSSLMODE=allow pg_dump ...
50+ *
51+ * @var string
52+ */
53+ private $ sslMode ;
3954
4055 /**
4156 * User to connect with
@@ -172,7 +187,7 @@ class Pgdump extends Abstraction implements Executable
172187 * @var string
173188 */
174189 private $ file ;
175-
190+
176191 /**
177192 * List of available output formats
178193 *
@@ -189,6 +204,20 @@ class Pgdump extends Abstraction implements Executable
189204 'tar ' => true ,
190205 ];
191206
207+ /**
208+ * List of available sslmode
209+ *
210+ * @var array
211+ */
212+ private $ availableSslMode = [
213+ 'disable ' => true ,
214+ 'allow ' => true ,
215+ 'prefer ' => true ,
216+ 'require ' => true ,
217+ 'verify-ca ' => true ,
218+ 'verify-full ' => true ,
219+ ];
220+
192221 /**
193222 * Constructor.
194223 *
@@ -238,6 +267,36 @@ public function usePort(int $port) : Pgdump
238267 return $ this ;
239268 }
240269
270+ /**
271+ * Define njobs tables simultaneously..
272+ *
273+ * @param int $jobs
274+ * @return \phpbu\App\Cli\Executable\Pgdump
275+ */
276+ public function dumpJobs (int $ jobs ): Pgdump
277+ {
278+ if ($ jobs < 0 ) {
279+ throw new Exception ('invalid jobs value ' );
280+ }
281+ $ this ->jobs = $ jobs ;
282+ return $ this ;
283+ }
284+
285+ /**
286+ * Set the sslmode
287+ *
288+ * @param string $sslMode
289+ * @return Pgdump
290+ */
291+ public function sslMode (string $ sslMode ): Pgdump
292+ {
293+ if ($ sslMode && !isset ($ this ->availableSslMode [$ sslMode ])) {
294+ throw new Exception ('invalid sslMode ' );
295+ }
296+ $ this ->sslMode = $ sslMode ;
297+ return $ this ;
298+ }
299+
241300 /**
242301 * Set database to dump.
243302 *
@@ -454,7 +513,8 @@ protected function createCommandLine() : CommandLine
454513 {
455514 $ process = new CommandLine ();
456515 $ password = $ this ->password ? 'PGPASSWORD= ' . escapeshellarg ($ this ->password ) . ' ' : '' ;
457- $ cmd = new Cmd ($ password . $ this ->binary );
516+ $ sslMode = $ this ->sslMode ? 'PGSSLMODE= ' . escapeshellarg ($ this ->sslMode ) . ' ' : '' ;
517+ $ cmd = new Cmd ($ sslMode . $ password . $ this ->binary );
458518 $ process ->addCommand ($ cmd );
459519
460520 // always disable password prompt
@@ -463,6 +523,7 @@ protected function createCommandLine() : CommandLine
463523 $ cmd ->addOptionIfNotEmpty ('--username ' , $ this ->user );
464524 $ cmd ->addOptionIfNotEmpty ('--host ' , $ this ->host );
465525 $ cmd ->addOptionIfNotEmpty ('--port ' , $ this ->port );
526+ $ cmd ->addOptionIfNotEmpty ('--jobs ' , $ this ->jobs );
466527 $ cmd ->addOptionIfNotEmpty ('--dbname ' , $ this ->databaseToDump );
467528 $ cmd ->addOptionIfNotEmpty ('--schema-only ' , $ this ->schemaOnly , false );
468529 $ cmd ->addOptionIfNotEmpty ('--data-only ' , $ this ->dataOnly , false );
@@ -471,6 +532,7 @@ protected function createCommandLine() : CommandLine
471532 $ cmd ->addOptionIfNotEmpty ('--encoding ' , $ this ->encoding );
472533 $ cmd ->addOptionIfNotEmpty ('--no-tablespaces ' , $ this ->noTablespaces , false );
473534 $ cmd ->addOptionIfNotEmpty ('--no-acl ' , $ this ->noPrivileges , false );
535+
474536
475537 $ this ->handleSchemas ($ cmd );
476538 $ this ->handleTables ($ cmd );
0 commit comments