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

Commitc870be6

Browse files
committed
New pg_upgrade command.
1 parent7d7adf2 commitc870be6

File tree

3 files changed

+145
-1
lines changed

3 files changed

+145
-1
lines changed

‎src/bin/pg_dump/Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/Makefile.in,v 1.9 1998/04/06 16:50:46 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/Makefile.in,v 1.10 1998/08/30 05:06:53 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -41,6 +41,7 @@ submake:
4141
install: pg_dump
4242
$(INSTALL)$(INSTL_EXE_OPTS) pg_dump$(BINDIR)/pg_dump
4343
$(INSTALL)$(INSTL_EXE_OPTS) pg_dumpall$(BINDIR)/pg_dumpall
44+
$(INSTALL)$(INSTL_EXE_OPTS) pg_upgrade$(BINDIR)/pg_upgrade
4445

4546
dependdep:
4647
$(CC) -MM$(CFLAGS)*.c>depend

‎src/bin/pg_dump/pg_upgrade

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
:
2+
trap "rm -f /tmp/$$" 0 1 2 3 15
3+
4+
if [ "$#" -eq 0 ]
5+
thenecho "Usage: $0 [-f inputfile] database" 1>&2
6+
exit 1
7+
fi
8+
9+
if [ "X$1" = "X-f" ]
10+
thenINPUT="$2"
11+
shift 2
12+
if [ ! -f "$INPUT" ]
13+
thenecho "$INPUT does not exist" 1>&2
14+
exit 1
15+
fi
16+
elseINPUT=""
17+
fi
18+
19+
if [ "$#" -ne 1 ]
20+
thenecho "Usage: $0 [-f input_file] database" 1>&2
21+
exit 1
22+
fi
23+
24+
DATABASE="$1"
25+
26+
# check things
27+
28+
if [ ! -f "./lib/global1.bki.source" ]
29+
thenecho "$0 must be run from the top of the postgres directory tree." 1>&2
30+
exit 1
31+
fi
32+
33+
if [ ! -d "./data.upgrade" ]
34+
thenecho "You must rename your old /data directory to /data.upgrade and run initdb." 1>&2
35+
exit 1
36+
fi
37+
38+
if [ ! -d "./data" ]
39+
thenecho "You must run initdb to create the template1 database." 1>&2
40+
exit 1
41+
fi
42+
43+
if [ ! -d "./data/base/template1" ]
44+
thenecho "$0 must be run as the postgres superuser." 1>&2
45+
exit 1
46+
fi
47+
48+
# do I need to create a database?
49+
50+
if [ "$DATABASE" != "template1" ]
51+
thendestroydb "$DATABASE"
52+
createdb "$DATABASE"
53+
fi
54+
55+
# remove COPY statements, preserve pgdump_oid setting from pg_dumpall
56+
57+
cat $INPUT | awk '{
58+
if (toupper($0) ~ /^COPY / &&
59+
toupper($0) !~ /^COPY[ ]*PGDUMP_OID/ )
60+
while (getline $0 > 0 && $0 != "\\.")
61+
;
62+
elseprint $0;
63+
}' >/tmp/$$
64+
65+
#create empty tables/indexes
66+
67+
psql "$DATABASE" <"/tmp/$$"
68+
set -x
69+
70+
for DIR in data/base/*
71+
do
72+
BASEDIR="`basename $DIR`"
73+
if [ -d "$DIR" -a \
74+
-d "data.upgrade/$DIR" -a \
75+
\( "$DATABASE" = "$BASEDIR" -o "$DATABASE" = "template1" \) ]
76+
thenfor FILE in data.upgrade/$DIR/*
77+
do
78+
BASEFILE="`basename $FILE`"
79+
if [ `expr "$BASEFILE" : "pg_"` -ne 3 -a \
80+
"$BASEFILE" != "PG_VERSION" ]
81+
thenmv $FILE $DIR
82+
fi
83+
done
84+
fi
85+
done
86+
87+
echo "You may removed the data.upgrade directory with 'rm -r data.upgrade'."

‎src/man/pg_upgrade.1

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.\" This is -*-nroff-*-
2+
.\" XXX standard disclaimer belongs here....
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_upgrade.1,v 1.1 1998/08/30 05:06:54 momjian Exp $
4+
.TH pg_upgrade UNIX 1/20/96 PostgreSQL PostgreSQL
5+
.SH NAME
6+
pg_upgrade - allows upgrade from a previous release without reloading data
7+
.SH SYNOPSIS
8+
.BR pg_upgrade
9+
[-f input_file] database
10+
.SH DESCRIPTION
11+
.IR"pg_upgrade"
12+
is a utility for upgrading from a previous PostgreSQL release
13+
without reloading all the data.
14+
First, to be safe, back up your data directory.
15+
Then, use:
16+
.nf
17+
18+
pg_dumpall -s -o >db.out
19+
20+
.fi
21+
to dump out your old database definitions without data,
22+
while perserving the max system oid.
23+
.PP
24+
Then rename (using
25+
.IR mv)
26+
your old pgsql /data directory to /data.upgrade and do a
27+
.IR"make install"
28+
to install the new binaries.
29+
Then run
30+
.IR initdb
31+
to create a new
32+
.IR template1
33+
database containing the system tables for the new release.
34+
.IR cd
35+
to the pgsql main directory, and type:
36+
.nf
37+
38+
pg_upgrade -f db.out template1
39+
40+
.fi
41+
The system will do some checking to make sure everything is properly
42+
configured, and run your
43+
.IR db.out
44+
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
46+
.IR /data
47+
directory.
48+
You can then start the
49+
.IR postmaster
50+
and check out the data.
51+
You can delete the
52+
.IR /data.upgrade
53+
directory when you are finished.
54+
.fi
55+
.SH "SEE ALSO"
56+
pg_dumpall(1).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp