/[rserv]/bin/Replicate
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/Replicate

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

revision 1.10 by dpavlin, Mon Oct 27 00:07:37 2003 UTC revision 1.12 by dpavlin, Thu Oct 30 19:59:48 2003 UTC
# Line 15  use strict; Line 15  use strict;
15  use IO::File;  use IO::File;
16  use Getopt::Long;  use Getopt::Long;
17  use RServ;  use RServ;
 use Sys::Hostname;  
18    
19  $| = 1;  $| = 1;
20    
# Line 23  my ($debug,$verbose) = (0,0); Line 22  my ($debug,$verbose) = (0,0);
22  my ($help,$masterhost,$masterport,$masteruser,$masterpassword,  my ($help,$masterhost,$masterport,$masteruser,$masterpassword,
23          $slavehost,$slaveport,$slaveuser,$slavepassword);          $slavehost,$slaveport,$slaveuser,$slavepassword);
24  my $snapshot = ".__Snapshot";  my $snapshot = ".__Snapshot";
25    my $mserver = 0;
26    
27  my $result = GetOptions(  my $result = GetOptions(
28          "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,          "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
# Line 31  my $result = GetOptions( Line 31  my $result = GetOptions(
31          "slavehost=s" => \$slavehost, "slaveport=i" => \$slaveport,          "slavehost=s" => \$slavehost, "slaveport=i" => \$slaveport,
32          "slaveuser=s" => \$slaveuser, "slavepassword=s" => \$slavepassword,          "slaveuser=s" => \$slaveuser, "slavepassword=s" => \$slavepassword,
33          "snapshot=s" => \$snapshot,          "snapshot=s" => \$snapshot,
34            "masterserver=i" => \$mserver,
35          );          );
36    
37  if (defined($help) || (scalar(@ARGV) < 2)) {  if (defined($help) || (scalar(@ARGV) < 2)) {
# Line 39  Options: Line 40  Options:
40          --masterhost=hostname --masterport=port          --masterhost=hostname --masterport=port
41          --masteruser=username --masterpassword=string          --masteruser=username --masterpassword=string
42          --snapshot=snapshot          --snapshot=snapshot
43            [--masterserver=master_number]
44  ";  ";
45      exit ((scalar(@ARGV) < 2)? 1:0);      exit ((scalar(@ARGV) < 2)? 1:0);
46  }  }
# Line 121  if ($sconn->status != Pg::PGRES_CONNECTI Line 123  if ($sconn->status != Pg::PGRES_CONNECTI
123      exit 1;      exit 1;
124  }  }
125    
126  $slavehost = hostname if (! $slavehost);  $slavehost = 'localhost' if (! $slavehost);
127  my $slaveId = GetSlaveId($mconn, $slave, $slavehost);  my $slaveId = GetSlaveId($mconn, $slave, $slavehost);
128    
129  die "\n>>>>>>>>>>>>> ERROR: Can't GetSlaveID for $sinfo\n" if (! $slaveId);  die "\n>>>>>>>>>>>>> ERROR: Can't GetSlaveID for $sinfo\n" if (! $slaveId);
130    
131  if ($slaveId < 0) {  if ($slaveId < 0) {
132      unlink $fname;      unlink $fname;
133      die "\n>>>>>>>>>>>>> ERROR\n";      die "\n>>>>>>>>>>>>> ERROR: GetSlaveID returned $slaveId < 0\n";
134  }  }
135  SyncSync($mconn, $sconn);  SyncSync($mconn, $sconn);
136    
137  my $outf = new IO::File;  my $outf = new IO::File;
138  open $outf, ">$snapshot";  open $outf, ">$snapshot";
139  print "\n>>>>>>>>>>>>> Prepare Snapshot\n\n" if ($verbose);  print "\n>>>>>>>>>>>>> Prepare Snapshot\n\n" if ($verbose);
140  my $res = PrepareSnapshot($mconn, $sconn, $outf, $slaveId, $tables);  print "master id: $mserver slave id: $slaveId\n" if ($debug);
141    my $res = PrepareSnapshot($mconn, $sconn, $outf, $mserver, $slaveId, $tables);
142  close $outf;  close $outf;
143  if ($res < 0) {  if ($res < 0) {
144      unlink $fname;      unlink $fname;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.26