/[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

Diff of /bin/ApplySnapshot

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by dpavlin, Wed Dec 20 17:22:35 2000 UTC revision 1.8 by dpavlin, Sun Nov 2 21:07:14 2003 UTC
# Line 1  Line 1 
1  # -*- perl -*-  #!/usr/bin/perl -w
2  # ApplySnapshot  # ApplySnapshot
3  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.
4    
# Line 6  eval '(exit $?0)' && eval 'exec perl -S Line 6  eval '(exit $?0)' && eval 'exec perl -S
6      & eval 'exec perl -S $0 $argv:q'      & eval 'exec perl -S $0 $argv:q'
7      if 0;      if 0;
8    
9  use lib "@LIBDIR@";  BEGIN {
10            my $basedir = $0; $basedir =~ s#/[^/]+$##;
11            unshift(@INC, "$basedir/../share");
12    }
13    
14    use strict;
15  use IO::File;  use IO::File;
16  use RServ;  use RServ;
17  use Getopt::Long;  use Getopt::Long;
18    
19  $| = 1;  $| = 1;
20    
21  $result = GetOptions("debug!", "verbose!", "help",  my ($debug,$verbose) = (0,0);
22                       "host=s", "user=s", "password=s");  my ($help,$slavehost,$slaveport,$slaveuser,$slavepassword,
23            $multimaster,
24  my $debug = $opt_debug || 0;  );
25  my $verbose = $opt_verbose || 0;  my $snapshot;
26  my $snapshot = $opt_snapshot || "__Snapshot";  
27    my $result = GetOptions(
28  if (defined($opt_help) || (scalar(@ARGV) < 1)) {          "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
29      print "Usage: $0 --host=name --user=name --password=string slavedb\n";          "slavehost=s" => \$slavehost, "slaveport=i" => \$slaveport,
30            "slaveuser=s" => \$slaveuser, "slavepassword=s" => \$slavepassword,
31            "multimaster" => \$multimaster,
32            "snapshot=s" => \$snapshot,
33            );
34    
35    if (defined($help) || (scalar(@ARGV) < 1)) {
36        print "Usage: $0 [options] slavedb
37    Options:
38            --slavehost=hostname --slaveport=port
39            --slaveuser=username --slavepassword=string
40            --multimaster
41            --snapshot=snapshot
42    ";
43      exit ((scalar(@ARGV) < 1)? 1:0);      exit ((scalar(@ARGV) < 1)? 1:0);
44  }  }
45    
46  my $slave = $ARGV[0] || "slave";  my $slave = $ARGV[0] || "slave";
47    
48  my $sinfo = "dbname=$slave";  my $sinfo = MkInfo($slave,$slavehost,$slaveport,$slaveuser,$slavepassword);
 $sinfo = "$sinfo host=$opt_host" if (defined($opt_host));  
 $sinfo = "$sinfo user=$opt_user" if (defined($opt_user));  
 $sinfo = "$sinfo password=$opt_password" if (defined($opt_password));  
49    
50  my $conn = Pg::connectdb(sinfo);  my $conn = Pg::connectdb($sinfo);
51    
52  my $inpf = new IO::File;  my $inpf;
53  $inpf = STDIN;  if (defined($snapshot)) {
54        $inpf = new IO::File;
55        $inpf->open("< $snapshot");
56    } else {
57        $inpf = *STDIN;
58    }
59    
60  $res = ApplySnapshot ($conn, $inpf);  my $res = ApplySnapshot ($conn, $inpf, $multimaster);
61    
62  if ($res > 0)  if ($res > 0)
63  {  {

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.26