trap "rm -f /tmp/$$" 0 1 2 3 15
if [ "$#" -eq 0 ]
-then echo "Usage: $0 [-f inputfile] database" 1>&2
+then echo "Usage: $0 [-f inputfile] old_data_dir database" 1>&2
exit 1
fi
else INPUT=""
fi
-if [ "$#" -ne 1 ]
-then echo "Usage: $0 [-f input_file] database" 1>&2
+if [ "$#" -ne 2 ]
+then echo "Usage: $0 [-f input_file] old_data_dir database" 1>&2
exit 1
fi
-DATABASE="$1"
+OLDDIR="$1"
+DATABASE="$2"
# check things
exit 1
fi
-if [ ! -d "./data.upgrade" ]
-then echo "You must rename your old /data directory to /data.upgrade and run initdb." 1>&2
+if [ ! -d "./$OLDDIR" ]
+then echo "You must rename your old /data directory to /$OLDDIR and run initdb." 1>&2
+ exit 1
+fi
+
+if [ ! -d "./$OLDDIR/data/base/$DATABASE" ]
+then echo "There is not database $DATABASE in ./$OLDDIR/data/base." 1>&2
exit 1
fi
# do I need to create a database?
if [ "$DATABASE" != "template1" ]
-then destroydb "$DATABASE"
+then echo "Dropping and recreating database $DATABASE." 1>&2
+ destroydb "$DATABASE" >/dev/null 2>&1
createdb "$DATABASE"
fi
-# remove COPY statements, preserve pgdump_oid setting from pg_dumpall
+# remove any COPY statements, preserve pgdump_oid setting from pg_dumpall
cat $INPUT | awk ' {
if (toupper($0) ~ /^COPY / &&
do
BASEDIR="`basename $DIR`"
if [ -d "$DIR" -a \
- -d "data.upgrade/$DIR" -a \
+ -d "$OLDDIR/$DIR" -a \
\( "$DATABASE" = "$BASEDIR" -o "$DATABASE" = "template1" \) ]
- then for FILE in data.upgrade/$DIR/*
+ then for FILE in $OLDDIR/$DIR/*
do
BASEFILE="`basename $FILE`"
if [ `expr "$BASEFILE" : "pg_"` -ne 3 -a \
fi
done
-echo "You may removed the data.upgrade directory with 'rm -r data.upgrade'."
+echo "You may removed the $OLDDIR directory with 'rm -r $OLDDIR'."
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_upgrade.1,v 1.2 1998/08/30 05:25:47 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_upgrade.1,v 1.3 1998/08/30 13:14:00 momjian Exp $
.TH pg_upgrade UNIX 1/20/96 PostgreSQL PostgreSQL
.SH NAME
pg_upgrade - allows upgrade from a previous release without reloading data
.SH SYNOPSIS
.BR pg_upgrade
-[-f input_file] database
+[-f input_file] old_data_dir database
.SH DESCRIPTION
.IR "pg_upgrade"
is a utility for upgrading from a previous PostgreSQL release
.PP
Then rename (using
.IR mv )
-your old pgsql /data directory to /data.upgrade and do a
+your old pgsql /data directory to /data.old and do a
.IR "make install"
to install the new binaries.
Then run
to the pgsql main directory, and type:
.nf
- pg_upgrade -f db.out template1
+ pg_upgrade -f db.out data.old template1
.fi
The system will do some checking to make sure everything is properly
configured, and run your
.IR db.out
script to create all the databases and tables you had, but with no data.
-It will then move the data files from /data.upgrade into the proper
+It will then move the data files from /data.old into the proper
.IR /data
directory.
You can then start the
.IR postmaster
and check out the data.
You can delete the
-.IR /data.upgrade
+.IR /data.old
directory when you are finished.
.PP
It can also be used for individual databases.