11<!--
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 $
33-->
44<chapter id="backup">
55 <title>Backup and Restore</title>
@@ -64,7 +64,7 @@ pg_dump <replaceable class="parameter">dbname</replaceable> > <replaceable cl
6464 <para>
6565 As any other <productname>PostgreSQL</> client application,
6666 <application>pg_dump</> will by default connect with the database
67- user name that is equal to the currentUnix user name. To override
67+ user name that is equal to the currentoperating system user name. To override
6868 this, either specify the <option>-U</option> option or set the
6969 environment variable <envar>PGUSER</envar>. Remember that
7070 <application>pg_dump</> connections are subject to the normal
@@ -104,9 +104,9 @@ psql <replaceable class="parameter">dbname</replaceable> < <replaceable class
104104</synopsis>
105105 where <replaceable class="parameter">infile</replaceable> is what
106106 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
108108 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
110110 <application>psql</> (e.g., with <literal>createdb -T template0
111111 <replaceable class="parameter">dbname</></literal>).
112112 <application>psql</> supports similar options to <application>pg_dump</>
@@ -129,23 +129,22 @@ psql <replaceable class="parameter">dbname</replaceable> < <replaceable class
129129 The ability of <application>pg_dump</> and <application>psql</> to
130130 write to or read from pipes makes it possible to dump a database
131131 directly from one server to another, for example
132- <informalexample>
133132<programlisting>
134133pg_dump -h <replaceable>host1</> <replaceable>dbname</> | psql -h <replaceable>host2</> <replaceable>dbname</>
135134</programlisting>
136- </informalexample>
137135 </para>
138136
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>
149148
150149 </sect2>
151150
@@ -222,20 +221,16 @@ cat <replaceable class="parameter">filename</replaceable>.gz | gunzip | psql <re
222221 acceptable in size to the underlying file system. For example, to
223222 make chunks of 1 megabyte:
224223
225- <informalexample>
226224<programlisting>
227225pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 1m - <replaceable class="parameter">filename</replaceable>
228226</programlisting>
229- </informalexample>
230227
231228 Reload with
232229
233- <informalexample>
234230<programlisting>
235231createdb <replaceable class="parameter">dbname</replaceable>
236232cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable class="parameter">dbname</replaceable>
237233</programlisting>
238- </informalexample>
239234 </para>
240235 </formalpara>
241236
@@ -249,14 +244,11 @@ cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable c
249244 restored selectively. The following command dumps a database using the
250245 custom dump format:
251246
252- <informalexample>
253247<programlisting>
254248pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable class="parameter">filename</replaceable>
255249</programlisting>
256- </informalexample>
257250
258251 See the <application>pg_dump</> and <application>pg_restore</> reference pages for details.
259-
260252 </para>
261253 </formalpara>
262254
@@ -284,7 +276,7 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable c
284276 <para>
285277 For reasons of backward compatibility, <application>pg_dump</> does
286278 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
288280 <application>pg_dump</>. See the reference pages for details.
289281 The directory <filename>contrib/pg_dumplo</> of the
290282 <productname>PostgreSQL</> source tree also contains a program that can
@@ -308,11 +300,10 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable c
308300 are located, but you have probably found them already if you are
309301 interested in this method. You can use whatever method you prefer
310302 for doing usual file system backups, for example
311- <informalexample>
303+
312304<programlisting>
313305tar -cf backup.tar /usr/local/pgsql/data
314306</programlisting>
315- </informalexample>
316307 </para>
317308
318309 <para>
@@ -390,11 +381,11 @@ tar -cf backup.tar /usr/local/pgsql/data
390381 The least downtime can be achieved by installing the new server in
391382 a different directory and running both the old and the new servers
392383 in parallel, on different ports. Then you can use something like
393- <informalexample>
384+
394385<programlisting>
395386pg_dumpall -p 5432 | psql -d template1 -p 6543
396387</programlisting>
397- </informalexample>
388+
398389 to transfer your data, or use an intermediate file if you want.
399390 Then you can shut down the old server and start the new server at
400391 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
410401 do the back up step before installing the new version, bring down
411402 the server, move the old version out of the way, install the new
412403 version, start the new server, restore the data. For example:
413- <informalexample>
404+
414405<programlisting>
415406pg_dumpall > backup
416407pg_ctl stop
@@ -421,7 +412,7 @@ initdb -D /usr/local/pgsql/data
421412postmaster -D /usr/local/pgsql/data
422413psql template1 < backup
423414</programlisting>
424- </informalexample>
415+
425416 See <xref linkend="runtime"> about ways to start and stop the
426417 server and other details. The installation instructions will advise
427418 you of strategic places to perform these steps.