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