diff options
| author | Bruce Momjian <bruce@momjian.us> | 1998-08-30 13:14:00 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 1998-08-30 13:14:00 +0000 |
| commit | 3b7d13a6b0e6c242ee87d43119781937b0554db5 (patch) | |
| tree | 2ea52a0a1ec0b537b1269a7dfd57ecfa3f4a8038 /src/bin | |
| parent | 2739315a80b2f431701e3eedee03b704c756da5f (diff) | |
| download | postgresql-3b7d13a6b0e6c242ee87d43119781937b0554db5.tar.gz | |
Make old db directory configurable.
Diffstat (limited to 'src/bin')
| -rwxr-xr-x | src/bin/pg_dump/pg_upgrade | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/bin/pg_dump/pg_upgrade b/src/bin/pg_dump/pg_upgrade index d65af38f68..06cf8e3411 100755 --- a/src/bin/pg_dump/pg_upgrade +++ b/src/bin/pg_dump/pg_upgrade @@ -2,7 +2,7 @@ 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 @@ -16,12 +16,13 @@ then INPUT="$2" 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 @@ -30,8 +31,13 @@ then echo "$0 must be run from the top of the postgres directory tree." 1>&2 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 @@ -48,11 +54,12 @@ 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 / && @@ -71,9 +78,9 @@ for DIR in data/base/* 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 \ @@ -84,4 +91,4 @@ do 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'." |
