Tue Mar 30 10:58:52 PDT 2010
- Previous message: [Slony1-commit] slony1-engine/src/slonik slonik.c
- Next message: [Slony1-commit] slony1-engine/tools slony1_extract_for_upgrade.sh slony1_extract_schema.sh
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/tools
In directory main.slony.info:/tmp/cvs-serv23391
Modified Files:
Tag: REL_1_2_STABLE
slony1_extract_schema.sh
Added Files:
Tag: REL_1_2_STABLE
slony1_extract_for_upgrade.sh
Log Message:
slony1_extract_schema.sh will now compare the major versions of postgres and pg_dump
to make sure they match.
Added slony1_extract_schema_for_upgrade.sh a wrapper script that will handle
the requried steps for getting a schema from an older postgres that can be
used as input to a newer version
Addresses bug # 114
Index: slony1_extract_schema.sh
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/tools/slony1_extract_schema.sh,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C 2 -d -r1.1 -r1.1.4.1
*** slony1_extract_schema.sh 3 Jan 2005 17:04:20 -0000 1.1
--- slony1_extract_schema.sh 30 Mar 2010 17:58:50 -0000 1.1.4.1
***************
*** 14,19 ****
exit 1
fi
-
- # ----
# Remember call arguments and get the nodeId of the DB specified
# ----
--- 14,17 ----
***************
*** 26,29 ****
--- 24,38 ----
# ----
+ # Check version
+ # ----
+ PGBINVER=`pg_dump --version|sed -e 's/.*\([0-9]+*\.[0-9]+*\)\.[0-9]*/\1/'`
+ PGBACKENDVER=`psql -q -At -c 'select version()' $dbname | sed -e 's/.*PostgreSQL \([0-8]+*\.[0-9]+*\).*/\1/'`
+ if [ "x$PGBINVER" != "x$PGBACKENDVER" ];
+ then
+ echo "Postgresql backend $PGBACKENDVER does not match pg_dump version $PGBINVER"
+ exit 1
+ fi
+ # ----
+ # ----
# Print a warning for sets originating remotely that their
# triggers and constraints will not be included in the dump.
--- NEW FILE: slony1_extract_for_upgrade.sh ---
#!/bin/sh
# ----------
# slony1_extract_for_upgrade
#
# Script to extract the user schema of a slony node in preperation
# for an upgrade of postgresql.
#
# This script will:
#
# 1) Call slony1_extract_schema.sh to extract the schema in the format
# suitable for the current pg version
# 2) Create a temp database and restore the schema to it
# 3) Use the pg_dump of the postgresql version you are upgrading to to
# dump the schema to a format suitable for restoring on the new
# postgresql.
#
#
# Note: This script requires slony1_extract_schema.sh to be in your $PATH
#
# ----------
# ----
# Check for correct usage
# ----
if test $# -ne 5 ; then
echo "usage: $0 dbname clustername tempdbname existing_pgbindir new_pgbindir" >&2
exit 1
fi
# Remember call arguments and get the nodeId of the DB specified
# ----
dbname=$1
cluster=$2
tmpdb=$3
existing_pgbindir=$4
new_pgbindir=$5
TMP=tmp_schema.$$
if [ $? -ne 0 ]
then
echo "error extracting existing schema"
exit 1
fi
if [ ! -f $existing_pgbindir/pg_dump ]
then
echo "error $existing_pgbindir does not contain pg_dump"
exit 1
fi
if [ ! -f $new_pgbindir/pg_dump ]
then
echo "error $new_pgbindir does not contain pg_dump"
exit 1
fi
###
# Step 1, extract the schema.
##
PATH=$existing_pgbindir:$PATH slony1_extract_schema.sh $dbname $cluster $tmpdb >$TMP.sql
createdb $tmpdb >/dev/null
if [ $? -ne 0 ]
then
echo "error creating temp db"
exit 1
fi
psql $tmpdb <$TMP.sql >/dev/null
if [ $? -ne 0 ]
then
echo "error restoring schema"
exit 1;
fi
$new_pgbindir/pg_dump -s $tmpdb
dropdb $tmpdb
- Previous message: [Slony1-commit] slony1-engine/src/slonik slonik.c
- Next message: [Slony1-commit] slony1-engine/tools slony1_extract_for_upgrade.sh slony1_extract_schema.sh
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list