/[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.3 - (show annotations)
Tue Aug 5 09:52:36 2003 UTC (20 years, 9 months ago) by dpavlin
Branch: MAIN
Changes since 1.2: +9 -6 lines
rserv 0.2 changes by Nélio Alves Pereira Filho

1 #!/usr/bin/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 "/usr/share/postgresql/contrib";
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", "snapshot=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 --snapshot=file 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;
38 if (defined($opt_snapshot)) {
39 $inpf = new IO::File;
40 $inpf->open("< $opt_snapshot");
41 } else {
42 $inpf = STDIN;
43 }
44
45 $res = ApplySnapshot ($conn, $inpf);
46
47 if ($res > 0)
48 {
49 printf STDERR "Snapshot applied\n";
50 }
51 elsif ($res != 0)
52 {
53 printf STDERR "ERROR\n";
54 exit(1);
55 }
56
57 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26