~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/pgarchivecleanup.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!-- doc/src/sgml/pgarchivecleanup.sgml -->
 
2
 
 
3
<sect1 id="pgarchivecleanup">
 
4
 <title>pg_archivecleanup</title>
 
5
 
 
6
 <indexterm zone="pgarchivecleanup">
 
7
  <primary>pg_archivecleanup</primary>
 
8
 </indexterm>
 
9
 
 
10
 <para>
 
11
  <application>pg_archivecleanup</> is designed to be used as an
 
12
  <literal>archive_cleanup_command</literal> to clean up WAL file archives when
 
13
  running as a standby server (see <xref linkend="warm-standby">).
 
14
  <application>pg_archivecleanup</> can also be used as a standalone program to
 
15
  clean WAL file archives.
 
16
 </para>
 
17
 
 
18
 <para>
 
19
  <application>pg_archivecleanup</application> features include:
 
20
 </para>
 
21
 <itemizedlist>
 
22
  <listitem>
 
23
   <para>
 
24
    Written in C, so very portable and easy to install
 
25
   </para>
 
26
  </listitem>
 
27
  <listitem>
 
28
   <para>
 
29
    Easy-to-modify source code, with specifically designated
 
30
    sections to modify for your own needs
 
31
   </para>
 
32
  </listitem>
 
33
 </itemizedlist>
 
34
 
 
35
 <sect2>
 
36
  <title>Usage</title>
 
37
 
 
38
  <para>
 
39
   To configure a standby
 
40
   server to use <application>pg_archivecleanup</>, put this into its
 
41
   <filename>recovery.conf</filename> configuration file:
 
42
<programlisting>
 
43
archive_cleanup_command = 'pg_archivecleanup <replaceable>archivelocation</> %r'
 
44
</programlisting>
 
45
   where <replaceable>archivelocation</> is the directory from which WAL segment
 
46
   files should be removed.
 
47
  </para>
 
48
  <para>
 
49
   When used within <xref linkend="archive-cleanup-command">, all WAL files
 
50
   logically preceding the value of the <literal>%r</> argument will be removed
 
51
   from <replaceable>archivelocation</>. This minimizes the number of files
 
52
   that need to be retained, while preserving crash-restart capability.  Use of
 
53
   this parameter is appropriate if the <replaceable>archivelocation</> is a
 
54
   transient staging area for this particular standby server, but
 
55
   <emphasis>not</> when the <replaceable>archivelocation</> is intended as a
 
56
   long-term WAL archive area, or when multiple standby servers are recovering
 
57
   from the same archive location.
 
58
  </para>
 
59
  <para>
 
60
   The full syntax of <application>pg_archivecleanup</>'s command line is
 
61
<synopsis>
 
62
pg_archivecleanup <optional> <replaceable>option</> ... </optional> <replaceable>archivelocation</> <replaceable>restartwalfile</>
 
63
</synopsis>
 
64
   When used as a standalone program all WAL files logically preceding the
 
65
   <literal>restartwalfile</> will be removed <replaceable>archivelocation</>.
 
66
   In this mode, if you specify a <filename>.backup</> file name, then only the file prefix
 
67
   will be used as the <literal>restartwalfile</>. This allows you to remove
 
68
   all WAL files archived prior to a specific base backup without error.
 
69
   For example, the following example will remove all files older than
 
70
   WAL file name <filename>000000010000003700000010</>:
 
71
<programlisting>
 
72
pg_archivecleanup -d archive 000000010000003700000010.00000020.backup
 
73
 
 
74
pg_archivecleanup:  keep WAL file "archive/000000010000003700000010" and later
 
75
pg_archivecleanup:  removing file "archive/00000001000000370000000F"
 
76
pg_archivecleanup:  removing file "archive/00000001000000370000000E"
 
77
</programlisting>
 
78
   <application>pg_archivecleanup</application> assumes that
 
79
   <replaceable>archivelocation</> is a directory readable and writable by the
 
80
   server-owning user.
 
81
  </para>
 
82
 </sect2>
 
83
 
 
84
 <sect2>
 
85
  <title><application>pg_archivecleanup</> Options</title>
 
86
 
 
87
   <para>
 
88
    <application>pg_archivecleanup</application> accepts the following command-line arguments:
 
89
 
 
90
    <variablelist>
 
91
 
 
92
     <varlistentry>
 
93
      <term><option>-d</option></term>
 
94
      <listitem>
 
95
       <para>
 
96
        Print lots of debug logging output on <filename>stderr</>.
 
97
       </para>
 
98
      </listitem>
 
99
     </varlistentry>
 
100
 
 
101
    </variablelist>
 
102
   </para>
 
103
 
 
104
 </sect2>
 
105
 
 
106
 <sect2>
 
107
  <title>Examples</title>
 
108
 
 
109
  <para>On Linux or Unix systems, you might use:
 
110
<programlisting>
 
111
archive_cleanup_command = 'pg_archivecleanup -d /mnt/standby/archive %r 2>>cleanup.log'
 
112
</programlisting>
 
113
   where the archive directory is physically located on the standby server,
 
114
   so that the <varname>archive_command</> is accessing it across NFS,
 
115
   but the files are local to the standby.
 
116
   This will:
 
117
  </para>
 
118
  <itemizedlist>
 
119
   <listitem>
 
120
    <para>
 
121
     produce debugging output in <filename>cleanup.log</>
 
122
    </para>
 
123
   </listitem>
 
124
   <listitem>
 
125
    <para>
 
126
     remove no-longer-needed files from the archive directory
 
127
    </para>
 
128
   </listitem>
 
129
  </itemizedlist>
 
130
 
 
131
 </sect2>
 
132
 
 
133
 <sect2>
 
134
  <title>Supported Server Versions</title>
 
135
 
 
136
  <para>
 
137
   <application>pg_archivecleanup</application> is designed to work with
 
138
   <productname>PostgreSQL</> 8.0 and later when used as a standalone utility,
 
139
   or with <productname>PostgreSQL</> 9.0 and later when used as an
 
140
   archive cleanup command.
 
141
  </para>
 
142
 </sect2>
 
143
 
 
144
 <sect2>
 
145
  <title>Author</title>
 
146
 
 
147
  <para>
 
148
   Simon Riggs <email>simon@2ndquadrant.com</email>
 
149
  </para>
 
150
 </sect2>
 
151
 
 
152
</sect1>