Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b7d13a

Browse files
committed
Make old db directory configurable.
1 parent2739315 commit3b7d13a

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

‎src/bin/pg_dump/pg_upgrade

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
trap "rm -f /tmp/$$" 0 1 2 3 15
33

44
if [ "$#" -eq 0 ]
5-
thenecho "Usage: $0 [-f inputfile] database" 1>&2
5+
thenecho "Usage: $0 [-f inputfile]old_data_dirdatabase" 1>&2
66
exit 1
77
fi
88

@@ -16,12 +16,13 @@ thenINPUT="$2"
1616
elseINPUT=""
1717
fi
1818

19-
if [ "$#" -ne1 ]
20-
thenecho "Usage: $0 [-f input_file] database" 1>&2
19+
if [ "$#" -ne2 ]
20+
thenecho "Usage: $0 [-f input_file]old_data_dirdatabase" 1>&2
2121
exit 1
2222
fi
2323

24-
DATABASE="$1"
24+
OLDDIR="$1"
25+
DATABASE="$2"
2526

2627
# check things
2728

@@ -30,8 +31,13 @@ thenecho "$0 must be run from the top of the postgres directory tree." 1>&2
3031
exit 1
3132
fi
3233

33-
if [ ! -d "./data.upgrade" ]
34-
thenecho "You must rename your old /data directory to /data.upgrade and run initdb." 1>&2
34+
if [ ! -d "./$OLDDIR" ]
35+
thenecho "You must rename your old /data directory to /$OLDDIR and run initdb." 1>&2
36+
exit 1
37+
fi
38+
39+
if [ ! -d "./$OLDDIR/data/base/$DATABASE" ]
40+
thenecho "There is not database $DATABASE in ./$OLDDIR/data/base." 1>&2
3541
exit 1
3642
fi
3743

@@ -48,11 +54,12 @@ fi
4854
# do I need to create a database?
4955

5056
if [ "$DATABASE" != "template1" ]
51-
thendestroydb "$DATABASE"
57+
thenecho "Dropping and recreating database $DATABASE." 1>&2
58+
destroydb "$DATABASE" >/dev/null 2>&1
5259
createdb "$DATABASE"
5360
fi
5461

55-
# remove COPY statements, preserve pgdump_oid setting from pg_dumpall
62+
# removeanyCOPY statements, preserve pgdump_oid setting from pg_dumpall
5663

5764
cat $INPUT | awk '{
5865
if (toupper($0) ~ /^COPY / &&
@@ -71,9 +78,9 @@ for DIR in data/base/*
7178
do
7279
BASEDIR="`basename $DIR`"
7380
if [ -d "$DIR" -a \
74-
-d "data.upgrade/$DIR" -a \
81+
-d "$OLDDIR/$DIR" -a \
7582
\( "$DATABASE" = "$BASEDIR" -o "$DATABASE" = "template1" \) ]
76-
thenfor FILE indata.upgrade/$DIR/*
83+
thenfor FILE in$OLDDIR/$DIR/*
7784
do
7885
BASEFILE="`basename $FILE`"
7986
if [ `expr "$BASEFILE" : "pg_"` -ne 3 -a \
@@ -84,4 +91,4 @@ do
8491
fi
8592
done
8693

87-
echo "You may removed thedata.upgrade directory with 'rm -rdata.upgrade'."
94+
echo "You may removed the$OLDDIR directory with 'rm -r$OLDDIR'."

‎src/man/pg_upgrade.1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.\" This is -*-nroff-*-
22
.\" XXX standard disclaimer belongs here....
3-
.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_upgrade.1,v 1.2 1998/08/3005:25:47 momjian Exp $
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_upgrade.1,v 1.3 1998/08/3013:14:00 momjian Exp $
44
.TH pg_upgrade UNIX 1/20/96 PostgreSQL PostgreSQL
55
.SH NAME
66
pg_upgrade - allows upgrade from a previous release without reloading data
77
.SH SYNOPSIS
88
.BR pg_upgrade
9-
[-f input_file] database
9+
[-f input_file]old_data_dirdatabase
1010
.SH DESCRIPTION
1111
.IR"pg_upgrade"
1212
is a utility for upgrading from a previous PostgreSQL release
@@ -23,7 +23,7 @@ while perserving the max system oid.
2323
.PP
2424
Then rename (using
2525
.IR mv)
26-
your old pgsql /data directory to /data.upgrade and do a
26+
your old pgsql /data directory to /data.old and do a
2727
.IR"make install"
2828
to install the new binaries.
2929
Then run
@@ -35,21 +35,21 @@ database containing the system tables for the new release.
3535
to the pgsql main directory, and type:
3636
.nf
3737

38-
pg_upgrade -f db.out template1
38+
pg_upgrade -f db.outdata.oldtemplate1
3939

4040
.fi
4141
The system will do some checking to make sure everything is properly
4242
configured, and run your
4343
.IR db.out
4444
script to create all the databases and tables you had, but with no data.
45-
It will then move the data files from /data.upgrade into the proper
45+
It will then move the data files from /data.old into the proper
4646
.IR /data
4747
directory.
4848
You can then start the
4949
.IR postmaster
5050
and check out the data.
5151
You can delete the
52-
.IR /data.upgrade
52+
.IR /data.old
5353
directory when you are finished.
5454
.PP
5555
It can also be used for individual databases.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp