blob: aa6a5226d53ac0c02151bf3bbbb1a2062305bde4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/bin/sh
#
# $FreeBSD$
#
# In postgresql.conf:
# archive_command = 'test -f /proj/pgsql/data/archive_log/%f || cp %p /proj/pgsql/data/archive_log/%f'
#
SRC=pgsql@$(hostname)
SRCDIR=$1
DEST=pgsql@$2
DESTDIR=$3
ARCLOG=$1/archive_log
logger="logger -t pgpool -p local0.info"
rsync="/usr/local/bin/rsync -av --delete --checksum"
excl="--exclude=pg_log --exclude=postmaster.pid"
psql="/usr/local/bin/psql"
/bin/sh <<EOF | ${logger} 2>&1
$psql -c "select pg_start_backup('pgpool-recovery')" template1
ssh $DEST "
/usr/local/bin/pg_ctl -D $DESTDIR -s -m fast stop;
rm -f $DESTDIR/backup_label"
echo "restore_command = 'scp $SRC:$ARCLOG/%f %p'" > $SRCDIR/recovery.conf
$rsync $SRCDIR/ $excl $DEST:/$DESTDIR/
ssh $DEST "
mkdir -p $DESTDIR/pg_xlog/archive_status;
mkdir -p $DESTDIR/pg_log"
rm -f $SRCDIR/recovery.conf
$psql -c 'select pg_stop_backup()' template1
EOF
|