Skip to content

Commit a7ff4a7

Browse files
committed
Add mention of recovery using pg_upgrade.
1 parent c69c25b commit a7ff4a7

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

contrib/pg_upgrade/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PostgreSQL lists.
77

88
Read the manual page for more information. To view it:
99

10-
nroff -man pg_upgrade.1 | $PAGER
10+
nroff -man pg_upgrade.1 | more
1111

1212
Bruce Momjian
1313

contrib/pg_upgrade/pg_upgrade

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# pg_upgrade: update a database without needing a full dump/reload cycle.
44
# CAUTION: Read the manual page before trying to use this!
55

6-
# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.10 2002/01/18 04:38:46 momjian Exp $
6+
# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.11 2002/01/31 19:13:53 momjian Exp $
77
#
88
# To migrate this to newer versions of PostgreSQL:
99
# 1) Update the version numbers at the top of the file
@@ -184,7 +184,7 @@ then
184184
exit 1
185185
fi
186186

187-
# Start server, if needed, so we can do some work.
187+
# If server is down, start it so we can do some work.
188188
if ! pg_ctl status | sed -n '1p' | grep "is running" > /dev/null 2>&1
189189
then pg_ctl -w start
190190
if [ $? -ne 0 ]
@@ -245,7 +245,8 @@ then
245245
make_dbobjoidmap > "$INFODIR"/dbobjoidmap || exit "$?"
246246

247247
# Generate setval() script for 7.1 because it has int4 sequences
248-
# Sequence XIDs changed from 7.2beta4 to beta5; we have to recreate them.
248+
# Sequence XIDs changed from 7.2beta4 to beta5 so we have to recreate them too.
249+
# Not required for 7.2beta5 and later, but it can't hurt.
249250
if [ "$SRC_VERSION" = "7.1" -o \
250251
"$SRC_VERSION" = "7.2" ]
251252
then
@@ -427,7 +428,7 @@ then echo "There were errors during VACUUM. Exiting." 1>&2
427428
exit 1
428429
fi
429430

430-
# Generate mappings for database
431+
# Generate mappings for new database
431432
make_dboidmap > /tmp/$$.dboidmap || exit "$?"
432433
make_dbobjoidmap > /tmp/$$.dbobjoidmap || exit "$?"
433434

contrib/pg_upgrade/pg_upgrade.1

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ pg_upgrade \- upgrading from a previous release without reloading
55
.SH SYNOPSIS
66
pg_upgrade [-D \fIdata_dir\fP] -1 | -2
77
.SH DESCRIPTION
8-
\fBpg_upgrade\fP is a utility for upgrading from a previous PostgreSQL release
9-
without reloading all the data. Not all PostgreSQL releases can use
10-
this utility. Check the release notes for details about your
11-
version.
12-
.LP
13-
\fBpg_upgrade\fP must be run in two stages. In phase one you must run
14-
\fBpg_upgrade\fP with your old database installation in place. In phase two,
15-
\fBpg_upgrade\fP must be run on a freshly \fBinitdb\fP'ed server.
8+
\fBpg_upgrade\fP is a utility for upgrading from a previous PostgreSQL
9+
release without reloading all the data. It can also be used as a data
10+
recovery tool.
11+
.LP
12+
\fBpg_upgrade\fP must be run in two stages. In phase one you must run
13+
\fBpg_upgrade\fP with your old database installation in place. In phase
14+
two, \fBpg_upgrade\fP must be run on a freshly \fBinitdb\fP'ed server.
1615
In both phases, the same newly installed \fBpg_upgrade\fP script must be
1716
used.
1817
.SH Upgrading PostgreSQL with pg_upgrade
1918
.LP
20-
1) Back up your existing data directory, preferably using \fBpg_dumpall.\fP
19+
1) Back up your existing data directory, preferably using
20+
\fBpg_dumpall.\fP
2121
.LP
22-
2) Copy the program \fIpgsql/contrib/pg_upgrade/pg_upgrade\fP from the current
23-
PostgreSQL distribution somewhere into your path.
22+
2) Copy the program \fIpgsql/contrib/pg_upgrade/pg_upgrade\fP from the
23+
current PostgreSQL distribution somewhere into your path.
2424
.LP
2525
3) Run phase one of \fBpg_upgrade:\fP
2626
.LP
2727
.B $ pg_upgrade -1
2828
.sp
2929
to collect information about the old database needed for the upgrade.
30-
You may use \fI-D\fP to specify the data directory. By default it uses
30+
You may use \fI-D\fP to specify the data directory. By default it uses
3131
the environment variable \fIPGDATA.\fP
3232
.LP
3333
4) Do:
@@ -51,9 +51,9 @@ to install the \fIpg_resetxlog\fP utility, which is needed during phase
5151
tables for the new release. Make sure you use settings similar to those
5252
used in your previous version.
5353
.LP
54-
7) Start the new \fIpostmaster.\fP (Note: it is critical that no users connect
55-
to the server until the upgrade is complete. You may wish to start the
56-
postmaster without -i or alter pg_hba.conf temporarily.)
54+
7) Start the new \fIpostmaster.\fP (Note: it is critical that no users
55+
connect to the server until the upgrade is complete. You may wish to
56+
start the postmaster without -i or alter pg_hba.conf temporarily.)
5757
.LP
5858
8) Run phase two of \fBpg_upgrade:\fP
5959
.LP
@@ -69,15 +69,30 @@ subdirectories.
6969
needed to allow user logins.
7070
.sp
7171
.LP
72-
10) Carefully examine the contents of the upgraded databases. If you
72+
10) Carefully examine the contents of the upgraded databases. If you
7373
detect problems, you'll need to recover by restoring from your full
74-
\fBpg_dumpall\fP backup. You can delete the \fIpg_upgrade_info/\fP directory when you
75-
are satisfied.
74+
\fBpg_dumpall\fP backup. You can delete the \fIpg_upgrade_info/\fP
75+
directory when you are satisfied.
7676
.LP
77-
The upgraded databases will be in an un-vacuumed state. You will
78-
probably want to run a \fIVACUUM ANALYZE\fP before beginning production work.
77+
The upgraded databases will be in an un-vacuumed state. You will
78+
probably want to run a \fIVACUUM ANALYZE\fP before beginning production
79+
work.
7980
.SH NOTES
8081
While \fBpg_upgrade\fP is primarly an upgrade tool, it can also be used
81-
as a data recovery tool.
82+
for data recovery. During phase 1, \fBpg_upgrade\fP creates database
83+
name / oid and database name / table name / oid mapping files in
84+
\fIpg_upgrade_info/.\fP These files are tab-delimited. If your system is
85+
too damaged, you may need to manually pull this information out of
86+
\fBpg_database\fP and \fBpg_class\fP and create the files manually.
87+
(Keep in mind most tables have \fBpg_toast_OID\fP and
88+
\fBpg_toast_OID_idx\fP files that store very long values. These must be
89+
recorded as well.) It also creates a schema-only \fBpg_dumpall.\fP In a
90+
damaged installation, you may be able to make one of these from a recent
91+
full \fBpg_dumpall.\fP
92+
.LP
93+
Phase 2 rebuilds each database with the schema from the old
94+
installation. It then moves the physical data files from the old
95+
installation and makes some modifications so the old data files work
96+
properly in the new installation.
8297
.SH SEE ALSO
8398
initdb(1), postmaster(1), pg_dump(1), pg_dumpall(1), vacuumdb(1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy