1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.33 2004/01/11 05:46:58 neilc Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.34 2004/01/19 20:12:30 tgl Exp $
3
3
-->
4
4
<chapter id="backup">
5
5
<title>Backup and Restore</title>
@@ -331,9 +331,7 @@ tar -cf backup.tar /usr/local/pgsql/data
331
331
The database server <emphasis>must</> be shut down in order to
332
332
get a usable backup. Half-way measures such as disallowing all
333
333
connections will not work as there is always some buffering
334
- going on. For this reason it is also not advisable to trust file
335
- systems that claim to support <quote>consistent
336
- snapshots</quote>. Information about stopping the server can be
334
+ going on. Information about stopping the server can be
337
335
found in <xref linkend="postmaster-shutdown">. Needless to say
338
336
that you also need to shut down the server before restoring the
339
337
data.
@@ -342,8 +340,8 @@ tar -cf backup.tar /usr/local/pgsql/data
342
340
343
341
<listitem>
344
342
<para>
345
- If you have dug into the details of the file system layout of the data you
346
- may be tempted to try to back up or restore only certain
343
+ If you have dug into the details of the file system layout of the
344
+ database, you may be tempted to try to back up or restore only certain
347
345
individual tables or databases from their respective files or
348
346
directories. This will <emphasis>not</> work because the
349
347
information contained in these files contains only half the
@@ -362,16 +360,30 @@ tar -cf backup.tar /usr/local/pgsql/data
362
360
<para>
363
361
An alternative file-system backup approach is to make a
364
362
<quote>consistent snapshot</quote> of the data directory, if the
365
- file system supports that functionality. Such a snapshot will save
363
+ file system supports that functionality (and you are willing to
364
+ trust that it is implemented correctly). The typical procedure is
365
+ to make a <quote>frozen snapshot</> of the volume containing the
366
+ database, then copy the whole data directory (not just parts, see
367
+ above) from the snapshot to a backup device, then release the frozen
368
+ snapshot. This will work even while the database server is running.
369
+ However, a backup created in this way saves
366
370
the database files in a state where the database server was not
367
371
properly shut down; therefore, when you start the database server
368
- on this backed up directory , it will think the server had crashed
372
+ on the backed- up data , it will think the server had crashed
369
373
and replay the WAL log. This is not a problem, just be aware of
370
374
it.
371
375
</para>
372
376
373
377
<para>
374
- Note that the file system backup will not necessarily be
378
+ If your database is spread across multiple volumes (for example,
379
+ data files and WAL log on different disks) there may not be any way
380
+ to obtain exactly-simultaneous frozen snapshots of all the volumes.
381
+ Read your filesystem documentation very carefully before trusting
382
+ to the consistent-snapshot technique in such situations.
383
+ </para>
384
+
385
+ <para>
386
+ Note that a file system backup will not necessarily be
375
387
smaller than an SQL dump. On the contrary, it will most likely be
376
388
larger. (<application>pg_dump</application> does not need to dump
377
389
the contents of indexes for example, just the commands to recreate
0 commit comments