1
- <!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.82 2006/08/06 03:53:43 tgl Exp $ -->
1
+ <!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.83 2006/08/17 23:04:02 tgl Exp $ -->
2
2
3
3
<chapter id="backup">
4
4
<title>Backup and Restore</title>
@@ -492,7 +492,7 @@ tar -cf backup.tar /usr/local/pgsql/data
492
492
the archiving will be done. Instead, <productname>PostgreSQL</> lets
493
493
the administrator specify a shell command to be executed to copy a
494
494
completed segment file to wherever it needs to go. The command could be
495
- as simple as a <application >cp</>, or it could invoke a complex shell
495
+ as simple as a <literal >cp</>, or it could invoke a complex shell
496
496
script — it's all up to you.
497
497
</para>
498
498
@@ -576,36 +576,6 @@ archive_command = 'test ! -f .../%f && cp %p .../%f'
576
576
it is working as you intend.
577
577
</para>
578
578
579
- <para>
580
- If you are concerned about being able to recover right up to the
581
- current instant, you may want to take additional steps to ensure that
582
- the current, partially-filled WAL segment is also copied someplace.
583
- This is particularly important if your server generates only little WAL
584
- traffic (or has slack periods where it does so), since it could take a
585
- long time before a WAL segment file is completely filled and ready to
586
- archive. One possible way to handle this is to set up a
587
- <application>cron</> job that periodically (once a minute, perhaps)
588
- identifies the current WAL segment file and saves it someplace safe.
589
- Then the combination of the archived WAL segments and the saved current
590
- segment will be enough to ensure you can always restore to within a
591
- minute of current time. This behavior is not presently built into
592
- <productname>PostgreSQL</> because we did not want to complicate the
593
- definition of the <xref linkend="guc-archive-command"> by requiring it
594
- to keep track of successively archived, but different, copies of the
595
- same WAL file. The <xref linkend="guc-archive-command"> is only
596
- invoked on completed WAL segments. Except in the case of retrying a
597
- failure, it will be called only once for any given file name.
598
- </para>
599
-
600
- <para>
601
- Another way to limit your exposure to data loss is to call
602
- <function>pg_switch_xlog()</> periodically, such as once a minute.
603
- This function forces the current WAL segment file to be completed
604
- and made available to the archiving command. This approach does
605
- not work well for extremely short update intervals, however, since
606
- copying a new 16MB segment file every few seconds is expensive.
607
- </para>
608
-
609
579
<para>
610
580
In writing your archive command, you should assume that the file names to
611
581
be archived may be up to 64 characters long and may contain any
@@ -626,6 +596,29 @@ archive_command = 'test ! -f .../%f && cp %p .../%f'
626
596
<xref linkend="runtime-config-file-locations"> for how to relocate the
627
597
configuration files.
628
598
</para>
599
+
600
+ <para>
601
+ The archive command is only invoked on completed WAL segments. Hence,
602
+ if your server generates only little WAL traffic (or has slack periods
603
+ where it does so), there could be a long delay between the completion
604
+ of a transaction and its safe recording in archive storage. To put
605
+ a limit on how old unarchived data can be, you can set
606
+ <xref linkend="guc-archive-timeout"> to force the server to switch
607
+ to a new WAL segment file at least that often. Note that archived
608
+ files that are ended early due to a forced switch are still the same
609
+ length as completely full files. It is therefore unwise to set a very
610
+ short <varname>archive_timeout</> — it will bloat your archive
611
+ storage. <varname>archive_timeout</> settings of a minute or so are
612
+ usually reasonable.
613
+ </para>
614
+
615
+ <para>
616
+ Also, you can force a segment switch manually with
617
+ <function>pg_switch_xlog()</>,
618
+ if you want to ensure that a just-finished transaction is archived
619
+ immediately. Other utility functions related to WAL management are
620
+ listed in <xref linkend="functions-admin-backup-table">.
621
+ </para>
629
622
</sect2>
630
623
631
624
<sect2 id="backup-base-backup">
0 commit comments