| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pg::CLI::pg_restore; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1696
|
use strict; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
27
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
23
|
|
|
5
|
1
|
|
|
1
|
|
435
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
19196
|
|
|
|
1
|
|
|
|
|
3
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
567
|
use Moose; |
|
|
1
|
|
|
|
|
449823
|
|
|
|
1
|
|
|
|
|
6
|
|
|
10
|
1
|
|
|
1
|
|
7711
|
use MooseX::SemiAffordanceAccessor; |
|
|
1
|
|
|
|
|
12631
|
|
|
|
1
|
|
|
|
|
3
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with qw( Pg::CLI::Role::Connects Pg::CLI::Role::Executable ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
|
15
|
|
|
|
|
|
|
sub _database_at_end { |
|
16
|
3
|
|
|
3
|
|
17
|
return 0; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _run_options { |
|
20
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
|
21
|
3
|
|
|
|
|
6
|
my $database = shift; |
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
7
|
return ( '-d', $database ); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
## use critic |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# ABSTRACT: Wrapper for the F<pg_restore> utility |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=pod |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=encoding UTF-8 |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Pg::CLI::pg_restore - Wrapper for the F<pg_restore> utility |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
version 0.14 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $pg_restore = Pg::CLI::pg_restore->new( |
|
50
|
|
|
|
|
|
|
username => 'foo', |
|
51
|
|
|
|
|
|
|
password => 'bar', |
|
52
|
|
|
|
|
|
|
host => 'pg.example.com', |
|
53
|
|
|
|
|
|
|
port => 5433, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$pg_restore->run( |
|
57
|
|
|
|
|
|
|
database => 'database', |
|
58
|
|
|
|
|
|
|
options => [ '-C' ], |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $sql; |
|
62
|
|
|
|
|
|
|
$pg_restore->run( |
|
63
|
|
|
|
|
|
|
database => 'database', |
|
64
|
|
|
|
|
|
|
options => ['-C'], |
|
65
|
|
|
|
|
|
|
stdin => \$sql, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This class provides a wrapper for the F<pg_restore> utility. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This class provides the following methods: |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 Pg::CLI::pg_restore->new( ... ) |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The constructor accepts a number of parameters: |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * executable |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The path to F<pg_restore>. By default, this will look for F<pg_restore> in your path |
|
85
|
|
|
|
|
|
|
and throw an error if it cannot be found. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * username |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The username to use when connecting to the database. Optional. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * password |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The password to use when connecting to the database. Optional. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * host |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The host to use when connecting to the database. Optional. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * port |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The port to use when connecting to the database. Optional. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * require_ssl |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
If this is true, then the C<PGSSLMODE> environment variable will be set to |
|
106
|
|
|
|
|
|
|
"require" when connecting to the database. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 $pg_restore->run( database => ..., options => [ ... ] ) |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This method restores the specified database. Any values passed in C<options> will |
|
113
|
|
|
|
|
|
|
be passed on to pg_restore. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This method also accepts optional C<stdin>, C<stdout>, and C<stderr> |
|
116
|
|
|
|
|
|
|
parameters. These parameters can be any defined value that could be passed as |
|
117
|
|
|
|
|
|
|
the relevant parameter to L<IPC::Run3>'s C<run3> subroutine. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Notably, you can capture the restore output in a scalar reference for the |
|
120
|
|
|
|
|
|
|
C<stdout> output. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 $pg_restore->version() |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Returns a the three part version as a string. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 $pg_restore->two_part_version() |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the first two decimal numbers in the version. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SUPPORT |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Bugs may be submitted at L<http://rt.cpan.org/Public/Dist/Display.html?Name=Pg-CLI> or via email to L<bug-pg-cli@rt.cpan.org|mailto:bug-pg-cli@rt.cpan.org>. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SOURCE |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The source code repository for Pg-CLI can be found at L<https://github.com/houseabsolute/Pg-CLI>. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is Copyright (c) 2018 by Dave Rolsky. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software, licensed under: |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
153
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |