14 |
$| = 1; |
$| = 1; |
15 |
|
|
16 |
$result = GetOptions("debug!", "verbose!", "help", |
$result = GetOptions("debug!", "verbose!", "help", |
17 |
"host=s", "user=s", "password=s"); |
"host=s", "user=s", "password=s", "snapshot=s"); |
18 |
|
|
19 |
my $debug = $opt_debug || 0; |
my $debug = $opt_debug || 0; |
20 |
my $verbose = $opt_verbose || 0; |
my $verbose = $opt_verbose || 0; |
21 |
my $snapshot = $opt_snapshot || "__Snapshot"; |
my $snapshot = $opt_snapshot || "__Snapshot"; |
22 |
|
|
23 |
if (defined($opt_help) || (scalar(@ARGV) < 1)) { |
if (defined($opt_help) || (scalar(@ARGV) < 1)) { |
24 |
print "Usage: $0 --host=name --user=name --password=string slavedb\n"; |
print "Usage: $0 --host=name --user=name --password=string --snapshot=file slavedb\n"; |
25 |
exit ((scalar(@ARGV) < 1)? 1:0); |
exit ((scalar(@ARGV) < 1)? 1:0); |
26 |
} |
} |
27 |
|
|
34 |
|
|
35 |
my $conn = Pg::connectdb($sinfo); |
my $conn = Pg::connectdb($sinfo); |
36 |
|
|
37 |
my $inpf = new IO::File; |
my $inpf; |
38 |
$inpf = STDIN; |
if (defined($opt_snapshot)) { |
39 |
|
$inpf = new IO::File; |
40 |
$RServ::quiet = !$verbose; |
$inpf->open("< $opt_snapshot"); |
41 |
|
} else { |
42 |
|
$inpf = STDIN; |
43 |
|
} |
44 |
|
|
45 |
$res = ApplySnapshot ($conn, $inpf); |
$res = ApplySnapshot ($conn, $inpf); |
46 |
|
|