1
- <!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.156 2010/06/07 02:01:08 itagaki Exp $ -->
1
+ <!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.157 2010/08/15 23:04:49 tgl Exp $ -->
2
2
3
3
<chapter id="backup">
4
4
<title>Backup and Restore</title>
20
20
<listitem><para>File system level backup</para></listitem>
21
21
<listitem><para>Continuous archiving</para></listitem>
22
22
</itemizedlist>
23
- Each has its own strengths and weaknesses; each is discussed in turn below.
23
+ Each has its own strengths and weaknesses; each is discussed in turn
24
+ in the following sections.
24
25
</para>
25
26
26
27
<sect1 id="backup-dump">
@@ -73,6 +74,16 @@ pg_dump <replaceable class="parameter">dbname</replaceable> > <replaceable cl
73
74
linkend="client-authentication">).
74
75
</para>
75
76
77
+ <para>
78
+ An important advantage of <application>pg_dump</> over the other backup
79
+ methods described later is that <application>pg_dump</>'s output can
80
+ generally be re-loaded into newer versions of <productname>PostgreSQL</>,
81
+ whereas file-level backups and continuous archiving are both extremely
82
+ server-version-specific. <application>pg_dump</> is also the only method
83
+ that will work when transferring a database to a different machine
84
+ architecture, such as going from a 32-bit to a 64-bit server.
85
+ </para>
86
+
76
87
<para>
77
88
Dumps created by <application>pg_dump</> are internally consistent,
78
89
meaning, the dump represents a snapshot of the database at the time
@@ -490,7 +501,7 @@ tar -cf backup.tar /usr/local/pgsql/data
490
501
<application>pg_dumpall</application> do not produce file-system-level
491
502
backups and cannot be used as part of a continuous-archiving solution.
492
503
Such dumps are <emphasis>logical</> and do not contain enough
493
- information to used by WAL reply .
504
+ information to be used by WAL replay .
494
505
</para>
495
506
</note>
496
507
@@ -1373,12 +1384,12 @@ archive_command = 'local_backup_script.sh'
1373
1384
1374
1385
<para>
1375
1386
<productname>PostgreSQL</> major versions are represented by the
1376
- first two digit groups of the version number, e.g. 8.4.
1387
+ first two digit groups of the version number, e.g., 8.4.
1377
1388
<productname>PostgreSQL</> minor versions are represented by the
1378
- the third group of version digits, i.e ., 8.4.2 is the second minor
1389
+ third group of version digits, e.g ., 8.4.2 is the second minor
1379
1390
release of 8.4. Minor releases never change the internal storage
1380
1391
format and are always compatible with earlier and later minor
1381
- releases of the same major version number, i.e. 8.4.2 is compatible
1392
+ releases of the same major version number, e.g., 8.4.2 is compatible
1382
1393
with 8.4, 8.4.1 and 8.4.6. To update between compatible versions,
1383
1394
you simply replace the executables while the server is down and
1384
1395
restart the server. The data directory remains unchanged —
@@ -1387,14 +1398,86 @@ archive_command = 'local_backup_script.sh'
1387
1398
1388
1399
<para>
1389
1400
For <emphasis>major</> releases of <productname>PostgreSQL</>, the
1390
- internal data storage format is subject to change. When migrating
1391
- data from one major version of <productname>PostgreSQL</> to another,
1392
- you need to back up your data and restore it on the new server.
1393
- This must be done using <application>pg_dump</>; file system level
1394
- backup methods will not work. There are checks in place that prevent
1401
+ internal data storage format is subject to change, thus complicating
1402
+ upgrades. The traditional method for moving data to a new major version
1403
+ is to dump and reload the database. Other, less-well-tested possibilities
1404
+ are available, as discussed below.
1405
+ </para>
1406
+
1407
+ <para>
1408
+ New major versions also typically introduce some user-visible
1409
+ incompatibilities, so application programming changes may be required.
1410
+ Cautious users will want to test their client applications on the new
1411
+ version before switching over fully; therefore, it's often a good idea to
1412
+ set up concurrent installations of old and new versions. When
1413
+ testing a <productname>PostgreSQL</> major upgrade, consider the
1414
+ following categories of possible changes:
1415
+ </para>
1416
+
1417
+ <variablelist>
1418
+
1419
+ <varlistentry>
1420
+ <term>Administration</term>
1421
+ <listitem>
1422
+ <para>
1423
+ The capabilities available for administrators to monitor and control
1424
+ the server often change and improve in each major release.
1425
+ </para>
1426
+ </listitem>
1427
+ </varlistentry>
1428
+
1429
+ <varlistentry>
1430
+ <term>SQL</term>
1431
+ <listitem>
1432
+ <para>
1433
+ Typically this includes new SQL command capabilities and not changes
1434
+ in behavior, unless specifically mentioned in the release notes.
1435
+ </para>
1436
+ </listitem>
1437
+ </varlistentry>
1438
+
1439
+ <varlistentry>
1440
+ <term>Library API</term>
1441
+ <listitem>
1442
+ <para>
1443
+ Typically libraries like <application>libpq</> only add new
1444
+ functionality, again unless mentioned in the release notes.
1445
+ </para>
1446
+ </listitem>
1447
+ </varlistentry>
1448
+
1449
+ <varlistentry>
1450
+ <term>System Catalogs</term>
1451
+ <listitem>
1452
+ <para>
1453
+ System catalog changes usually only affect database management tools.
1454
+ </para>
1455
+ </listitem>
1456
+ </varlistentry>
1457
+
1458
+ <varlistentry>
1459
+ <term>Server C-language API</term>
1460
+ <listitem>
1461
+ <para>
1462
+ This involves changes in the backend function API, which is written
1463
+ in the C programming language. Such changes affect code that
1464
+ references backend functions deep inside the server.
1465
+ </para>
1466
+ </listitem>
1467
+ </varlistentry>
1468
+
1469
+ </variablelist>
1470
+
1471
+ <sect2 id="migration-methods-pgdump">
1472
+ <title>Migrating data via <application>pg_dump</></title>
1473
+
1474
+ <para>
1475
+ To dump data from one major version of <productname>PostgreSQL</> and
1476
+ reload it in another, you must use <application>pg_dump</>; file system
1477
+ level backup methods will not work. (There are checks in place that prevent
1395
1478
you from using a data directory with an incompatible version of
1396
- <productname>PostgreSQL</productname>, so no great harm can be done
1397
- by trying to start the wrong server version on a data directory.
1479
+ <productname>PostgreSQL</productname>, so no great harm can be done by
1480
+ trying to start the wrong server version on a data directory.)
1398
1481
</para>
1399
1482
1400
1483
<para>
@@ -1414,26 +1497,15 @@ archive_command = 'local_backup_script.sh'
1414
1497
pg_dumpall -p 5432 | psql -d postgres -p 6543
1415
1498
</programlisting>
1416
1499
1417
- to transfer your data. Or use an intermediate file if you wish.
1500
+ to transfer your data. Or you can use an intermediate file if you wish.
1418
1501
Then you can shut down the old server and start the new server using
1419
1502
the port the old one was running on. You should make sure that the
1420
1503
old database is not updated after you begin to run
1421
- <application>pg_dumpall</>, otherwise you will lose that data . See <xref
1422
- linkend="client-authentication"> for information on how to prohibit
1504
+ <application>pg_dumpall</>, otherwise you will lose those updates . See
1505
+ <xref linkend="client-authentication"> for information on how to prohibit
1423
1506
access.
1424
1507
</para>
1425
1508
1426
- <para>
1427
- It is also possible to use replication methods, such as
1428
- <productname>Slony</>, to create a standby server with the updated version of
1429
- <productname>PostgreSQL</>. The standby can be on the same computer or
1430
- a different computer. Once it has synced up with the master server
1431
- (running the older version of <productname>PostgreSQL</>), you can
1432
- switch masters and make the standby the master and shut down the older
1433
- database instance. Such a switch-over results in only several seconds
1434
- of downtime for an upgrade.
1435
- </para>
1436
-
1437
1509
<para>
1438
1510
If you cannot or do not want to run two servers in parallel, you can
1439
1511
do the backup step before installing the new version, bring down
@@ -1474,68 +1546,33 @@ psql -f backup postgres
1474
1546
moving an installation like this will not work.)
1475
1547
</para>
1476
1548
</note>
1549
+ </sect2>
1550
+
1551
+ <sect2 id="migration-methods-other">
1552
+ <title>Other data migration methods</title>
1477
1553
1478
1554
<para>
1479
- In practice you probably want to test your client applications on the
1480
- new version before switching over completely. This is another reason
1481
- for setting up concurrent installations of old and new versions. When
1482
- testing a <productname>PostgreSQL</> major upgrade, consider the
1483
- following categories of possible changes:
1555
+ The <filename>contrib</> program
1556
+ <link linkend="pgupgrade"><application>pg_upgrade</application></link>
1557
+ allows an installation to be migrated in-place from one major
1558
+ <productname>PostgreSQL</> version to the next. Keep in mind that this
1559
+ method does not provide any scope for running old and new versions
1560
+ concurrently. Also, <application>pg_upgrade</application> is much less
1561
+ battle-tested than <application>pg_dump</application>, so having an
1562
+ up-to-date backup is strongly recommended in case something goes wrong.
1484
1563
</para>
1485
1564
1486
- <variablelist>
1487
-
1488
- <varlistentry>
1489
- <term>Administration</term>
1490
- <listitem>
1491
- <para>
1492
- The capabilities available for administrators to monitor and control
1493
- the server often change and improve in each major release.
1494
- </para>
1495
- </listitem>
1496
- </varlistentry>
1497
-
1498
- <varlistentry>
1499
- <term>SQL</term>
1500
- <listitem>
1501
- <para>
1502
- Typically this includes new SQL command capabilities and not changes
1503
- in behavior, unless specifically mentioned in the release notes.
1504
- </para>
1505
- </listitem>
1506
- </varlistentry>
1507
-
1508
- <varlistentry>
1509
- <term>Library API</term>
1510
- <listitem>
1511
- <para>
1512
- Typically libraries like <application>libpq</> only add new
1513
- functionality, again unless mentioned in the release notes.
1514
- </para>
1515
- </listitem>
1516
- </varlistentry>
1517
-
1518
- <varlistentry>
1519
- <term>System Catalogs</term>
1520
- <listitem>
1521
- <para>
1522
- System catalog changes usually only affect database management tools.
1523
- </para>
1524
- </listitem>
1525
- </varlistentry>
1526
-
1527
- <varlistentry>
1528
- <term>Server C-language API</term>
1529
- <listitem>
1530
- <para>
1531
- This involved changes in the backend function API, which is written
1532
- in the C programming language. Such changes effect code that
1533
- references backend functions deep inside the server.
1534
- </para>
1535
- </listitem>
1536
- </varlistentry>
1537
-
1538
- </variablelist>
1565
+ <para>
1566
+ It is also possible to use certain replication methods, such as
1567
+ <productname>Slony</>, to create a standby server with the updated version of
1568
+ <productname>PostgreSQL</>. The standby can be on the same computer or
1569
+ a different computer. Once it has synced up with the master server
1570
+ (running the older version of <productname>PostgreSQL</>), you can
1571
+ switch masters and make the standby the master and shut down the older
1572
+ database instance. Such a switch-over results in only several seconds
1573
+ of downtime for an upgrade.
1574
+ </para>
1539
1575
1576
+ </sect2>
1540
1577
</sect1>
1541
1578
</chapter>
0 commit comments