/[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.5 - (show annotations)
Fri Aug 15 23:00:27 2003 UTC (20 years, 8 months ago) by dpavlin
Branch: MAIN
CVS Tags: before_onlytables, before_multmaster, r_0_3
Changes since 1.4: +1 -1 lines
Snapshot fixes

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 = "dbname=$slave";
45 $sinfo = "$sinfo host=$slavehost" if (defined($slavehost));
46 $sinfo = "$sinfo port=$slaveport" if (defined($slaveport));
47 $sinfo = "$sinfo user=$slaveuser" if (defined($slaveuser));
48 $sinfo = "$sinfo password=$slavepassword" if (defined($slavepassword));
49
50 my $conn = Pg::connectdb($sinfo);
51
52 my $inpf;
53 if (defined($snapshot)) {
54 $inpf = new IO::File;
55 $inpf->open("< $snapshot");
56 } else {
57 $inpf = *STDIN;
58 }
59
60 my $res = ApplySnapshot ($conn, $inpf);
61
62 if ($res > 0)
63 {
64 printf STDERR "Snapshot applied\n";
65 }
66 elsif ($res != 0)
67 {
68 printf STDERR "ERROR\n";
69 exit(1);
70 }
71
72 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26