1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/backup.sgml,v 2.23 2002/10/21 02:11:37 tgl Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/backup.sgml,v 2.24 2002/11/11 20:14:02 petere Exp $
3
3
-->
4
4
<chapter id="backup">
5
5
<title>Backup and Restore</title>
@@ -64,7 +64,7 @@ pg_dump <replaceable class="parameter">dbname</replaceable> > <replaceable cl
64
64
<para>
65
65
As any other <productname>PostgreSQL</> client application,
66
66
<application>pg_dump</> will by default connect with the database
67
- user name that is equal to the current Unix user name. To override
67
+ user name that is equal to the current operating system user name. To override
68
68
this, either specify the <option>-U</option> option or set the
69
69
environment variable <envar>PGUSER</envar>. Remember that
70
70
<application>pg_dump</> connections are subject to the normal
@@ -104,9 +104,9 @@ psql <replaceable class="parameter">dbname</replaceable> < <replaceable class
104
104
</synopsis>
105
105
where <replaceable class="parameter">infile</replaceable> is what
106
106
you used as <replaceable class="parameter">outfile</replaceable>
107
- for the pg_dump command. The database <replaceable
107
+ for the <command> pg_dump</> command. The database <replaceable
108
108
class="parameter">dbname</replaceable> will not be created by this
109
- command, you must create it yourself from template0 before executing
109
+ command, you must create it yourself from <literal> template0</> before executing
110
110
<application>psql</> (e.g., with <literal>createdb -T template0
111
111
<replaceable class="parameter">dbname</></literal>).
112
112
<application>psql</> supports similar options to <application>pg_dump</>
@@ -129,23 +129,22 @@ psql <replaceable class="parameter">dbname</replaceable> < <replaceable class
129
129
The ability of <application>pg_dump</> and <application>psql</> to
130
130
write to or read from pipes makes it possible to dump a database
131
131
directly from one server to another, for example
132
- <informalexample>
133
132
<programlisting>
134
133
pg_dump -h <replaceable>host1</> <replaceable>dbname</> | psql -h <replaceable>host2</> <replaceable>dbname</>
135
134
</programlisting>
136
- </informalexample>
137
135
</para>
138
136
139
-
140
- <important>
141
- <para>
142
- The dumps produced by pg_dump are relative to template0. This means
143
- that any languages, procedures, etc. added to template1 will also be
144
- dumped by <application>pg_dump</>. As a result, when restoring, if
145
- you are using a customized template1, you must create the empty
146
- database from template0, as in the example above.
147
- </para>
148
- </important>
137
+ <important>
138
+ <para>
139
+ The dumps produced by <application>pg_dump</> are relative to
140
+ <literal>template0</>. This means that any languages, procedures,
141
+ etc. added to <literal>template1</> will also be dumped by
142
+ <application>pg_dump</>. As a result, when restoring, if you are
143
+ using a customized <literal>template1</>, you must create the
144
+ empty database from <literal>template0</>, as in the example
145
+ above.
146
+ </para>
147
+ </important>
149
148
150
149
</sect2>
151
150
@@ -222,20 +221,16 @@ cat <replaceable class="parameter">filename</replaceable>.gz | gunzip | psql <re
222
221
acceptable in size to the underlying file system. For example, to
223
222
make chunks of 1 megabyte:
224
223
225
- <informalexample>
226
224
<programlisting>
227
225
pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 1m - <replaceable class="parameter">filename</replaceable>
228
226
</programlisting>
229
- </informalexample>
230
227
231
228
Reload with
232
229
233
- <informalexample>
234
230
<programlisting>
235
231
createdb <replaceable class="parameter">dbname</replaceable>
236
232
cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable class="parameter">dbname</replaceable>
237
233
</programlisting>
238
- </informalexample>
239
234
</para>
240
235
</formalpara>
241
236
@@ -249,14 +244,11 @@ cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable c
249
244
restored selectively. The following command dumps a database using the
250
245
custom dump format:
251
246
252
- <informalexample>
253
247
<programlisting>
254
248
pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable class="parameter">filename</replaceable>
255
249
</programlisting>
256
- </informalexample>
257
250
258
251
See the <application>pg_dump</> and <application>pg_restore</> reference pages for details.
259
-
260
252
</para>
261
253
</formalpara>
262
254
@@ -284,7 +276,7 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable c
284
276
<para>
285
277
For reasons of backward compatibility, <application>pg_dump</> does
286
278
not dump large objects by default. To dump large objects you must use
287
- either the custom or the TAR output format, and use the -b option in
279
+ either the custom or the TAR output format, and use the <option>-b</> option in
288
280
<application>pg_dump</>. See the reference pages for details.
289
281
The directory <filename>contrib/pg_dumplo</> of the
290
282
<productname>PostgreSQL</> source tree also contains a program that can
@@ -308,11 +300,10 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable c
308
300
are located, but you have probably found them already if you are
309
301
interested in this method. You can use whatever method you prefer
310
302
for doing usual file system backups, for example
311
- <informalexample>
303
+
312
304
<programlisting>
313
305
tar -cf backup.tar /usr/local/pgsql/data
314
306
</programlisting>
315
- </informalexample>
316
307
</para>
317
308
318
309
<para>
@@ -390,11 +381,11 @@ tar -cf backup.tar /usr/local/pgsql/data
390
381
The least downtime can be achieved by installing the new server in
391
382
a different directory and running both the old and the new servers
392
383
in parallel, on different ports. Then you can use something like
393
- <informalexample>
384
+
394
385
<programlisting>
395
386
pg_dumpall -p 5432 | psql -d template1 -p 6543
396
387
</programlisting>
397
- </informalexample>
388
+
398
389
to transfer your data, or use an intermediate file if you want.
399
390
Then you can shut down the old server and start the new server at
400
391
the port the old one was running at. You should make sure that the
@@ -410,7 +401,7 @@ pg_dumpall -p 5432 | psql -d template1 -p 6543
410
401
do the back up step before installing the new version, bring down
411
402
the server, move the old version out of the way, install the new
412
403
version, start the new server, restore the data. For example:
413
- <informalexample>
404
+
414
405
<programlisting>
415
406
pg_dumpall > backup
416
407
pg_ctl stop
@@ -421,7 +412,7 @@ initdb -D /usr/local/pgsql/data
421
412
postmaster -D /usr/local/pgsql/data
422
413
psql template1 < backup
423
414
</programlisting>
424
- </informalexample>
415
+
425
416
See <xref linkend="runtime"> about ways to start and stop the
426
417
server and other details. The installation instructions will advise
427
418
you of strategic places to perform these steps.
0 commit comments