/[rserv]/bin/ApplySnapshot
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/ApplySnapshot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Sun Nov 2 10:21:45 2003 UTC (20 years, 6 months ago) by dpavlin
Branch: MAIN
Changes since 1.5: +1 -5 lines
moved all info preparation into MkInfo in RServ.pm

1 #!/usr/bin/perl -w
2 # ApplySnapshot
3 # Vadim Mikheev, (c) 2000, PostgreSQL Inc.
4
5 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
6 & eval 'exec perl -S $0 $argv:q'
7 if 0;
8
9 BEGIN {
10 my $basedir = $0; $basedir =~ s#/[^/]+$##;
11 unshift(@INC, "$basedir/../share");
12 }
13
14 use strict;
15 use IO::File;
16 use RServ;
17 use Getopt::Long;
18
19 $| = 1;
20
21 my ($debug,$verbose) = (0,0);
22 my ($help,$slavehost,$slaveport,$slaveuser,$slavepassword);
23 my $snapshot;
24
25 my $result = GetOptions(
26 "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
27 "slavehost=s" => \$slavehost, "slaveport=i" => \$slaveport,
28 "slaveuser=s" => \$slaveuser, "slavepassword=s" => \$slavepassword,
29 "snapshot=s" => \$snapshot,
30 );
31
32 if (defined($help) || (scalar(@ARGV) < 1)) {
33 print "Usage: $0 [options] slavedb
34 Options:
35 --slavehost=hostname --slaveport=port
36 --slaveuser=username --slavepassword=string
37 --snapshot=snapshot
38 ";
39 exit ((scalar(@ARGV) < 1)? 1:0);
40 }
41
42 my $slave = $ARGV[0] || "slave";
43
44 my $sinfo = MkInfo($slave,$slavehost,$slaveport,$slaveuser,$slavepassword);
45
46 my $conn = Pg::connectdb($sinfo);
47
48 my $inpf;
49 if (defined($snapshot)) {
50 $inpf = new IO::File;
51 $inpf->open("< $snapshot");
52 } else {
53 $inpf = *STDIN;
54 }
55
56 my $res = ApplySnapshot ($conn, $inpf);
57
58 if ($res > 0)
59 {
60 printf STDERR "Snapshot applied\n";
61 }
62 elsif ($res != 0)
63 {
64 printf STDERR "ERROR\n";
65 exit(1);
66 }
67
68 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26