File: README.Debian.migration

package info (click to toggle)
postgresql 6.5.3-27
  • links: PTS
  • area: main
  • in suites: potato
  • size: 28,360 kB
  • ctags: 20,905
  • sloc: ansic: 204,608; yacc: 10,718; sql: 9,387; sh: 9,379; java: 8,835; tcl: 7,709; makefile: 3,376; lex: 1,642; perl: 1,034; python: 959; cpp: 847; asm: 70; pascal: 42; awk: 10; sed: 8
file content (234 lines) | stat: -rw-r--r-- 9,610 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
Software updates
================

Major software updates frequently require the database to be reloaded.
Having considered this carefully, I think it too risky to let
dpkg handle this automatically with the preinst and postinst scripts. Apart
from the dangers of loss of data, a large database could delay the
installation of other packages for a long time.

If the upgrade requires a reload, the new package will conflict
with all older versions of postgresql and all versions of postgres95.
In the case of postgres95, this is an actual package Conflict.  In the
case of successive releases of postgresql, the conflict is handled
by the preinst and postinst scripts.


************************************************************************
*                    Which upgrade method to use?                      *
************************************************************************

If you already had a Debian package installed, look below for the
appropriate section.  The major distribution releases are highlighted
in asterisk boxes.

Distribution releases were:

??     rex       ?
??     buzz      ?
1.?    bo        6?
2.0    hamm      6.3.2-5
2.1    slink     6.3.2-15
2.2    potato    6.5.3-19

However, since you may have upgraded the package independently of the
main distribution, this may not be helpful.  You can find the database
version by logging in as `postgres' and doing `cat ${PGDATA}/PG_VERSION'.


Manual upgrade procedure
========================

WARNING: You will have problems if you upgrade in large steps (for
instance from 6.1 to 6.4).  This is because at each release the upstream
developers assume that you are upgrading from the immediately preceding
release.  If you upgrade at longer intervals, incompatibilities may
arise between the pg_dump of the previous version and the database
infrastructure of the new version.  In such circumstances, you will 
probably have to edit your dump file before you can restore your data.
This will make you considerably more expert in the use of regular
expressions...

Follow this procedure to dump your old database:


1) Upgrading from 6.2.1 and above to later versions of PostgreSQL
=================================================================

The preinst scripts of libpgsql and postgresql should capture some of
the executables and shared libraries of an earlier package release.  These
are stored in /usr/lib/postgresql/dumpall/<release>.  These executables
are saved so that they can be used to dump the old database.  Once your
database is up-to-date, there is no need to retain these executables and the
directory that they are saved in can be deleted.

Provided that these executables have been successfully captured, the
old database can be dumped, deleted and reloaded by the command
postgresql-dump.  This must be run by the PostgreSQL administrator,
postgres.  See the postgresql-dump manpage for full details of how to
use it.

a) pg_upgrade method 
--------------------
** This method is not usable for going from Debian 2.1 to Debian 2.2 **

For upgrades to version 6.4 and later, except across the boundary between
6.4.2 and 6.5, the best way to run postgresql-dump is:

	# su - postgres
	$ postgresql-dump -t db.out -ucil

which uses the pg_upgrade command introduced at PostgreSQL 6.4.  This
method requires only the database structure to be dumped; the data
itself is read from the old database.  This method does require
two copies of data on the disk at once, so will need to have enough
disk space.  This method cannot be used to upgrade from 6.4 or below
to 6.5 or above.  (See section (b) below.)


************************************************
*  Debian release 2.1 "slink" to 2.2 "potato"  *
************************************************

b) *** Moving from 6.4.2 or earlier to 6.5 or later ***
-------------------------------------------------------

The internal structure of tables changed at release 6.5, so it is not
possible to use pg_upgrade for a move to (or through) 6.5. You have to do
a complete dump and reload.

At 6.5, the use of the keyword `current' in CREATE RULE to refer to the
table being updated was changed to `old'.  Dump scripts produced by 6.4.2
and earlier will therefore not load correctly on 6.5, because all 
occurrences of `current.' have to be changed to `old.'.  postgresql-dump 
will do this for you if you give it the option -f.  This option passes
the dump file through "sed -e '/^CREATE RULE /s/current\./old./g'". If
this is wrong for your data but your data needs conversion, you should
dump the data, edit it and then reload it.  A close study of the manual
page for postgresql-dump is recommended.

The recommended upgrade command for <=6.4.2 to >=6.5 is

   # su - postgres
   $ postgresql-dump -t db.out -cilfdp $PGDATA/../data.save

which is nearly the same as the command for versions before 6.4.

c) before 6.4
-------------
If you have plenty of disk space you can do an automatic full dump and
restore like this (this is the method that had to be used until release
6.4 became available):

	# su - postgres
	$ postgresql-dump -t db.out -dcilp $PGDATA/../data.save

This will dump the database to db.out, in the postgres home directory,
list the dump on screen for the user to inspect and approve, destroy the
old database, create the new database with initdb and finally reload the
data from db.out into the new database.   The old database will be saved
in $PGDATA/../data.save in case anything goes wrong.


If you do not have enough space for multiple copies of your data, you
can use single options of postgresql-dump to do the dump and restore
one bit at a time.  For example:

    postgresql-dump -t /dev/st0               # dump to tape
    postgresql-dump -c -t /dev/st0            # check tape dump
    postgresql-dump -d -t /dev/st0 -i -l      # destroy the old database
                                              # create a new one and
                                              # load the dump

It is highly recommended, of course, that you should have a backup of
${PGDATA} before destroying the database!


2) Upgrading from postgres95 or any non-Debianised version of Postgres
======================================================================

If the preinstallation script finds a data/base directory where it
expects to put its own, or if it finds an executable called postgres
in /usr/bin, it will assume there is an older version installed
and will attempt to capture the old executables as described above.
If it succeeds, it will put them in /usr/lib/postgresql/dumpall/unknown.

Otherwise the installation should fail, and you will have to do a manual
dump and restore before you can continue, like this:

Check in the FAQ, in this documentation, whether and how to dump your data.
Some older versions require you to load intermediate versions in 
order to preserve data integrity through to the current version.
For example, you cannot go directly from Postgres95 1.08 to PostgreSQL 6;
you must dump and reload into Postgres95 1.09 first.

Older versions of the dump_all command were liable to lose data about
SQL permissions and users.  You may have to live with this.

Make sure you have an up-to-date backup; be wary of using normal Linux backup
utilities while the database is being vacuumed, or you may find on recovery
that your database is corrupt.  

$ su - postgres               # become the Postgres superuser
$ pg_dumpall >target_file     # target_file may be a tape or on disk

When this procedure is complete, read through the resulting archive
to ensure that it is correct and can be read to the end.  The dump
format is ASCII text. As at release 6.2.1, pg_dumpall loses table
ownerships and permissions.  At 6.5 it has fairly few problems.

When you are completely satisfied that you have a readable backup of
your database:

(PGDATA should be set; if it isn't, set it thus:

$ export PGDATA=/path_to_database/data
$ export PGLIB=/usr/lib/postgresql
)
$ $PGLIB/bin/cleardbdir
(if, for some reason, that didn't work:
  $ rm -rf $PGDATA/*
)

This will destroy the old Postgres95 or PostgreSQL database, so don't
do it until you are absolutely certain about your data!

Finish this orgy of destruction by removing the old package:

# dpkg --remove postgres95 libpq1 postgres95-dev postgres95-doc

or find the various files and delete them if Postgres wasn't Debianised
before.

When the database has been destroyed, create a new one with initdb.

Start the postmaster (as root):

# /etc/init.d/postgresql start

Finally, reload your database:

# su - postgres
$ psql -e <target_file

(If you are unlucky, you may have to do more or less extensive editing
of target_file before you can reload it.)


Co-existing with local installations
====================================

If someone has created a local copy of PostgreSQL, in /usr/local/pgsql,
for example, the two copies will clash, because both will be listening
on port 5432.  One of the postmasters will be unable to start, because
it will be blocked by the exisiting socket /tmp/.s.PGSQL.5432, which the
other will have opened.

If you do not wish to delete the local copy, you must make sure that the
two copies use different databases ($PGDATA) and listen on different
ports.  You can either reconfigure and recompile the local version, or
make sure it and its front-ends alway runs with PGPORT set to the
desired port, or you can set the value of PGPORT in
/etc/postgresql/postmaster.init.  Do not use 5341, because that is
used by the installation scripts for special purposes.  Do not use any
port that is used by any TCP/IP service.