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

Commit2913d65

Browse files
committed
Preserver pg_log and pg_variable in upgrade. Cleanups.
1 parenta753e5d commit2913d65

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

‎src/bin/pg_dump/pg_upgrade

Lines changed: 15 additions & 20 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] old_data_dir database" 1>&2
5+
thenecho "Usage: $0 [-f inputfile] old_data_dir" 1>&2
66
exit 1
77
fi
88

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

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

2424
OLDDIR="$1"
25-
DATABASE="$2"
2625

2726
# check things
2827

@@ -36,8 +35,8 @@ thenecho "You must rename your old /data directory to /$OLDDIR and run initdb."
3635
exit 1
3736
fi
3837

39-
if [ ! -d "./$OLDDIR/data/base/$DATABASE" ]
40-
thenecho "There is not database$DATABASE in ./$OLDDIR/data/base." 1>&2
38+
if [ ! -d "./$OLDDIR/base/template1" ]
39+
thenecho "There is not databasetemplate1 in ./$OLDDIR/base." 1>&2
4140
exit 1
4241
fi
4342

@@ -53,34 +52,27 @@ fi
5352

5453
# do I need to create a database?
5554

56-
if [ "$DATABASE" != "template1" ]
57-
thenecho "Dropping and recreating database $DATABASE." 1>&2
58-
destroydb "$DATABASE" >/dev/null 2>&1
59-
createdb "$DATABASE"
60-
fi
61-
62-
# remove any COPY statements, preserve pgdump_oid setting from pg_dumpall
55+
# remove any COPY statements
56+
# we don't even need pgdump_oid because we are moving pg_variable
57+
# then shouldn't be in there anyway
6358

6459
cat $INPUT | awk '{
65-
if (toupper($0) ~ /^COPY / &&
66-
toupper($0) !~ /^COPY[ ]*PGDUMP_OID/ )
60+
if (toupper($0) ~ /^COPY /)
6761
while (getline $0 > 0 && $0 != "\\.")
6862
;
6963
elseprint $0;
7064
}' >/tmp/$$
7165

7266
#create empty tables/indexes
7367

74-
psql "$DATABASE" <"/tmp/$$"
75-
set -x
68+
psql "template1" <"/tmp/$$"
7669

7770
for DIR in data/base/*
7871
do
7972
BASEDIR="`basename $DIR`"
8073
if [ -d "$DIR" -a \
81-
-d "$OLDDIR/$DIR" -a \
82-
\( "$DATABASE" = "$BASEDIR" -o "$DATABASE" = "template1" \) ]
83-
thenfor FILE in $OLDDIR/$DIR/*
74+
-d "$OLDDIR/base/$BASEDIR" -a \( "$BASEDIR" != "template1" \) ]
75+
thenfor FILE in $OLDDIR/base/$BASEDIR/*
8476
do
8577
BASEFILE="`basename $FILE`"
8678
if [ `expr "$BASEFILE" : "pg_"` -ne 3 -a \
@@ -91,4 +83,7 @@ do
9183
fi
9284
done
9385

86+
mv $OLDDIR/pg_log data
87+
mv $OLDDIR/pg_variable data
88+
9489
echo "You may removed the $OLDDIR directory with 'rm -r $OLDDIR'."

‎src/man/pg_upgrade.1

Lines changed: 9 additions & 12 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.3 1998/08/30 13:14:00 momjian Exp $
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_upgrade.1,v 1.4 1998/08/31 04:32:18 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] old_data_dir database
9+
[-f input_file] old_data_dir
1010
.SH DESCRIPTION
1111
.IR"pg_upgrade"
1212
is a utility for upgrading from a previous PostgreSQL release
@@ -15,27 +15,28 @@ First, to be safe, back up your data directory.
1515
Then, use:
1616
.nf
1717

18-
pg_dumpall -s-o>db.out
18+
pg_dumpall -s >db.out
1919

2020
.fi
21-
to dump out your old database definitions without data,
22-
while perservingthemax system oid.
21+
to dump out your old database definitions withoutanydata.
22+
Stopthepostmaster and all backends.
2323
.PP
2424
Then rename (using
2525
.IR mv)
2626
your old pgsql /data directory to /data.old and do a
2727
.IR"make install"
2828
to install the new binaries.
29-
Then run
29+
Run
3030
.IR initdb
3131
to create a new
3232
.IR template1
3333
database containing the system tables for the new release.
34+
Start the new postmaster,
3435
.IR cd
3536
to the pgsql main directory, and type:
3637
.nf
3738

38-
pg_upgrade -f db.out data.old template1
39+
pg_upgrade -f db.out data.old
3940

4041
.fi
4142
The system will do some checking to make sure everything is properly
@@ -45,13 +46,9 @@ script to create all the databases and tables you had, but with no data.
4546
It will then move the data files from /data.old into the proper
4647
.IR /data
4748
directory.
48-
You can then start the
49-
.IR postmaster
50-
and check out the data.
49+
You can then check out the data.
5150
You can delete the
5251
.IR /data.old
5352
directory when you are finished.
54-
.PP
55-
It can also be used for individual databases.
5653
.SH "SEE ALSO"
5754
pg_dumpall(1).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp