Skip to content

Commit 54f2b60

Browse files
author
Thomas G. Lockhart
committed
rserv replication toolkit from Vadim Mikheev.
1 parent 96edf0c commit 54f2b60

19 files changed

+2644
-0
lines changed

contrib/rserv/ApplySnapshot.in

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# -*- perl -*-
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+
use lib "@LIBDIR@";
10+
use IO::File;
11+
use RServ;
12+
use Getopt::Long;
13+
14+
$| = 1;
15+
16+
$result = GetOptions("debug!", "verbose!", "help",
17+
"host=s", "user=s", "password=s");
18+
19+
my $debug = $opt_debug || 0;
20+
my $verbose = $opt_verbose || 0;
21+
my $snapshot = $opt_snapshot || "__Snapshot";
22+
23+
if (defined($opt_help) || (scalar(@ARGV) < 1)) {
24+
print "Usage: $0 --host=name --user=name --password=string slavedb\n";
25+
exit ((scalar(@ARGV) < 1)? 1:0);
26+
}
27+
28+
my $slave = $ARGV[0] || "slave";
29+
30+
my $sinfo = "dbname=$slave";
31+
$sinfo = "$sinfo host=$opt_host" if (defined($opt_host));
32+
$sinfo = "$sinfo user=$opt_user" if (defined($opt_user));
33+
$sinfo = "$sinfo password=$opt_password" if (defined($opt_password));
34+
35+
my $conn = Pg::connectdb(sinfo);
36+
37+
my $inpf = new IO::File;
38+
$inpf = STDIN;
39+
40+
$res = ApplySnapshot ($conn, $inpf);
41+
42+
if ($res > 0)
43+
{
44+
printf STDERR "Snapshot applied\n";
45+
}
46+
elsif ($res != 0)
47+
{
48+
printf STDERR "ERROR\n";
49+
exit(1);
50+
}
51+
52+
exit(0);

contrib/rserv/CleanLog.in

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# -*- perl -*-
2+
# CleanLog
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+
use lib "@LIBDIR@";
10+
11+
use Getopt::Long;
12+
use RServ;
13+
14+
$| = 1;
15+
16+
$result = GetOptions("debug!", "verbose!", "help", "snapshot=s",
17+
"host=s", "user=s", "password=s");
18+
19+
my $debug = $opt_debug || 0;
20+
my $verbose = $opt_verbose || 0;
21+
my $snapshot = $opt_snapshot || "__Snapshot";
22+
23+
if (defined($opt_help) || (scalar(@ARGV) < 2) || ($ARGV[1] !~ /^\d+$/)) {
24+
print "Usage: $PROGRAM_NAME --host=name --user=name --password=string masterdb syncid\n";
25+
exit ((scalar(@ARGV) < 2)? 1: 0);
26+
}
27+
28+
my $dbname = $ARGV[0];
29+
my $howold = $ARGV[1];
30+
31+
my $minfo = "dbname=$dbname";
32+
$minfo = "$minfo host=$opt_host" if (defined($opt_host));
33+
$minfo = "$minfo user=$opt_user" if (defined($opt_user));
34+
$minfo = "$minfo password=$opt_password" if (defined($opt_password));
35+
36+
print "Master connection is $minfo\n" if ($debug);
37+
print "Slave connection is $sinfo\n" if ($debug);
38+
39+
my $conn = Pg::connectdb($minfo);
40+
41+
$res = CleanLog($conn, $howold);
42+
43+
exit(1) if $res < 0;
44+
45+
printf STDERR "Deleted %d log records\n", $res if $res > 0;
46+
47+
exit(0);

contrib/rserv/GetSyncID.in

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- perl -*-
2+
# GetSyncID
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+
use lib "@LIBDIR@";
10+
11+
use Pg;
12+
use Getopt::Long;
13+
use RServ;
14+
15+
$| = 1;
16+
17+
my $verbose = 1;
18+
19+
$result = GetOptions("debug!", "verbose!", "help",
20+
"host=s", "user=s", "password=s");
21+
22+
my $debug = $opt_debug || 0;
23+
my $verbose = $opt_verbose if (defined($opt_verbose));
24+
25+
if (defined($opt_help) || (scalar(@ARGV) < 1)) {
26+
print "Usage: $0 --host=name --user=name --password=string slavedb\n";
27+
exit ((scalar(@ARGV) < 1)? 1: 0);
28+
}
29+
30+
my $dbname = $ARGV[0];
31+
32+
my $sinfo = "dbname=$dbname";
33+
$sinfo = "$sinfo host=$opt_host" if (defined($opt_host));
34+
$sinfo = "$sinfo user=$opt_user" if (defined($opt_user));
35+
$sinfo = "$sinfo password=$opt_password" if (defined($opt_password));
36+
37+
if ($verbose) { print "Connecting to '$sinfo'\n" };
38+
my $conn = Pg::connectdb($sinfo);
39+
40+
$res = GetSyncID($conn);
41+
42+
die "ERROR\n" if $res < 0;
43+
44+
if (! defined $res)
45+
{
46+
printf STDERR "No SyncID found\n";
47+
}
48+
else
49+
{
50+
print("Last SyncID applied: ") if ($verbose);
51+
printf "%d", $res;
52+
print("\n") if ($verbose);
53+
}
54+
55+
exit(0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy