++ed by:

2 PAUSE users
1 non-PAUSE user.

Dave Rolsky
and 1 contributors


Pg::CLI::pg_restore - Wrapper for the pg_restore utility


version 0.13


  my $pg_restore = Pg::CLI::pg_restore->new(
      username => 'foo',
      password => 'bar',
      host     => 'pg.example.com',
      port     => 5433,

      database => 'database',
      options  => [ '-C' ],

  my $sql;
      database => 'database',
      options  => ['-C'],
      stdin    => \$sql,


This class provides a wrapper for the pg_restore utility.


This class provides the following methods:

Pg::CLI::pg_restore->new( ... )

The constructor accepts a number of parameters:

  • executable

    The path to pg_restore. By default, this will look for pg_restore in your path and throw an error if it cannot be found.

  • username

    The username to use when connecting to the database. Optional.

  • password

    The password to use when connecting to the database. Optional.

  • host

    The host to use when connecting to the database. Optional.

  • port

    The port to use when connecting to the database. Optional.

  • require_ssl

    If this is true, then the PGSSLMODE environment variable will be set to "require" when connecting to the database.

$pg_restore->run( database => ..., options => [ ... ] )

This method restores the specified database. Any values passed in options will be passed on to pg_restore.

This method also accepts optional stdin, stdout, and stderr parameters. These parameters can be any defined value that could be passed as the relevant parameter to IPC::Run3's run3 subroutine.

Notably, you can capture the restore output in a scalar reference for the stdout output.


Returns a the three part version as a string.


Returns the first two decimal numbers in the version.


Bugs may be submitted at http://rt.cpan.org/Public/Dist/Display.html?Name=Pg-CLI or via email to bug-pg-cli@rt.cpan.org.

I am also usually active on IRC as 'autarch' on irc://irc.perl.org.


The source code repository for Pg-CLI can be found at https://github.com/houseabsolute/Pg-CLI.


Dave Rolsky <autarch@urth.org>


This software is Copyright (c) 2018 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution.