Imported Upstream version 3.3.1
[debian/amanda] / man / xml-source / ampgsql.8.xml
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3                    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
4 [
5   <!-- entities files to use -->
6   <!ENTITY % global_entities SYSTEM 'global.entities'>
7   %global_entities;
8 ]>
9
10 <refentry id='ampgsql.8'>
11
12 <refmeta>
13 <refentrytitle>ampgsql</refentrytitle>
14 <manvolnum>8</manvolnum>
15 &rmi.source;
16 &rmi.version;
17 &rmi.manual.8;
18 </refmeta>
19 <refnamediv>
20 <refname>ampgsql</refname>
21 <refpurpose>Amanda Application to interface with PostgreSQL</refpurpose>
22 </refnamediv>
23 <refentryinfo>
24 &author.ncoukouma;
25 </refentryinfo>
26 <!-- body begins here -->
27
28 <refsect1><title>DESCRIPTION</title>
29
30 <para>Ampgsql is an Amanda Application API script.  It should not be run
31 by users directly.  It implements on-line backups of PostgreSQL databases
32 in conjunction with WAL archiving.</para>
33
34 <note><para>Tablespaces are not currently supported.</para></note>
35
36 <note><para>On versions of PostgreSQL earlier than 8.2, if the database is
37 quiet during a full backup, then the backup may not complete until
38 enough database activity takes place to trigger the archiving of the
39 current WAL file.  Consider adjusting the PG-MAX-WAL-WAIT property from
40 its default (60s) to compensate.  Note that you will need to increase
41 <option>dtimeout</option> on the server accordingly.</para></note>
42
43 </refsect1>
44
45 <refsect1><title>OPERATION</title>
46
47 <para>This application implements the backup strategy described in <ulink
48 url="http://www.postgresql.org/docs/current/static/continuous-archiving.html"
49 >http://www.postgresql.org/docs/current/static/continuous-archiving.html</ulink>.
50 For a level zero (full) backup, ampgsql:
51 <itemizedlist>
52     <listitem><para>execute PG_START_BACKUP()</para></listitem>
53     <listitem><para>dump the data directory</para></listitem>
54     <listitem><para>execute PG_STOP_BACKUP()</para></listitem>
55     <listitem><para>wait for the final WAL file to be archived</para></listitem>
56     <listitem><para>back up the required WAL files</para></listitem>
57     <listitem><para>optionally delete WAL files that are no longer necessary</para></listitem>
58 </itemizedlist>
59 The two dumps are made with GNU Tar, to <filename>data_dir.tar</filename> and
60 <filename>archive_dir</filename>, respectively.  They are then combined into a
61 single tar file.</para>
62
63 <para>A level N backup creates a single tar file containing all WAL files since the
64 previous level N-1 backup.</para>
65
66 </refsect1>
67
68 <refsect1><title>PROPERTIES</title>
69
70 <para>This section lists the <manref name="amanda.conf" vol="5"/> properties that control ampsql's functionality.
71 See <manref name="amanda-applications" vol="7"/>
72 for information on application properties and how they are configured.</para>
73
74 <!-- PLEASE KEEP THIS LIST IN ALPHABETICAL ORDER -->
75 <variablelist>
76  <!-- ==== -->
77  <varlistentry><term>ARCHIVEDIR</term><listitem>
78 <para>Directory that WAL segment files are archived to, as specified by the
79 archive_command in PosgreSQL's postgresql.conf.  The amanda user on the
80 client must have at least read and execute permission on this directory,
81 and preferably write.  Without write permission, Amanda cannot clean up
82 expired WAL and backup files.</para>
83 </listitem></varlistentry>
84  <!-- ==== -->
85  <varlistentry><term>CLEANUPWAL</term><listitem>
86 <para>Whether or not to remove old WAL segment files during base backups.
87 Defaults to yes.</para>
88 </listitem></varlistentry>
89  <!-- ==== -->
90  <varlistentry><term>DB</term><listitem>
91 <para>Database to connect to. Defaults to "template1" (which exists by
92 default).</para>
93 </listitem></varlistentry>
94  <!-- ==== -->
95  <varlistentry><term>DIRECTORY</term><listitem>
96 <para>For restore command only, the data is recoved in that directory.
97 Must be a unix path.</para>
98 </listitem></varlistentry>
99  <!-- ==== -->
100  <varlistentry><term>GNUTAR-PATH</term><listitem>
101 <para>Path to the GNU tar executable. This option only has an effect
102 during restore.  The default is set when Amanda is built by the
103 --with-gnutar configure option.</para>
104 </listitem></varlistentry>
105  <!-- ==== -->
106  <varlistentry><term>HOST</term><listitem>
107 <para>Host to connect to. If it starts with "/" it will be interepreted as a
108 directory that holds the socket file. PostgreSQL defaults to /tmp.</para>
109 </listitem></varlistentry>
110  <!-- ==== -->
111  <varlistentry><term>MAX-WAL-WAIT</term><listitem>
112 <para>The maximum amount of time to wait for PG_STOP_BACKUP to archive a WAL
113 file.  In versions of PostgreSQL before 8.2, PG_STOP_BACKUP does not
114 automatically archive the latest WAL file, so a quiet database may
115 wait a very long time before archiving the WAL file.  Default: 60
116 seconds.  Set to 0 to wait forever.</para>
117 </listitem></varlistentry>
118  <!-- ==== -->
119  <varlistentry><term>PASSFILE</term><listitem>
120 <para>Connect using the creditials in this file. Each line should have the
121 format "hostname:port:database:username:password". The permissions must
122 permit it to be read only by the user, or the file will not be used.
123 Only usable with Postgres 8.1 and up.</para>
124 </listitem></varlistentry>
125  <!-- ==== -->
126  <varlistentry><term>PORT</term><listitem>
127 <para>The TCP port to connect to, or the suffix of the socket file. PostgreSQL
128 defaults to 5432.</para>
129 </listitem></varlistentry>
130  <!-- ==== -->
131  <varlistentry><term>PSQL-PATH</term><listitem>
132 <para>Path to the psql binary. If not specified, the PATH environment variable
133 will be searched.</para>
134 </listitem></varlistentry>
135  <!-- ==== -->
136  <varlistentry><term>STATEDIR</term><listitem>
137 <para>Directory for saving state about backups already made. The default is set
138 when Amanda is built by the --with-gnutar-listdir configure option.</para>
139 </listitem></varlistentry>
140  <!-- ==== -->
141  <varlistentry><term>TMPDIR</term><listitem>
142 <para>Directory to use for temporary files during the backup process. It should
143 have enough space to store a complete copy of the database. The default is set
144 when Amanda is built by the --with-tmpdir configure option.</para>
145 </listitem></varlistentry>
146  <!-- ==== -->
147  <varlistentry><term>USER</term><listitem>
148 <para>User to connect as. It must be a superuser.</para>
149 </listitem></varlistentry>
150
151 </variablelist>
152
153 </refsect1>
154
155 <refsect1><title>CLIENT PROPERTIES</title>
156
157 <para>Client properties are deprecated. All properties should be set in
158 the dumptype.</para>
159
160 <para>This section lists the <manref name="amanda-client.conf" vol="5"/> properties that control ampsql's functionality.
161 If a property is prefixed with the diskname and an underscore,
162 then it will be used when that diskname is being backed up.
163 For example, if the properties PG-DATADIR and foo-PG-DATADIR are set,
164 the value of PG-DATADIR will be used when bar and baz are being backed up,
165 but foo-PG-DATADIR will be used when foo is being backed up.
166 Disknames are specified in the <manref name="disklist" vol="5"/>.
167 </para>
168
169 <!-- PLEASE KEEP THIS LIST IN ALPHABETICAL ORDER -->
170 <variablelist>
171  <!-- ==== -->
172  <varlistentry><term>PG-ARCHIVEDIR</term><listitem>
173 Directory that WAL segment files are archived to, as specified by the archive_command
174 in PosgreSQL's postgresql.conf.  The amanda user on the client must have at least read
175 and execute permission on this directory, and preferably write.  Without write permission,
176 Amanda cannot clean up expired WAL and backup files.
177 </listitem></varlistentry>
178  <!-- ==== -->
179  <varlistentry><term>PG-CLEANUPWAL</term><listitem>
180 Whether or not to remove old WAL segment files during base backups.
181 Defaults to yes.
182 </listitem></varlistentry>
183  <!-- ==== -->
184  <varlistentry><term>PG-DATADIR</term><listitem>
185 Cluster data directory
186 </listitem></varlistentry>
187  <!-- ==== -->
188  <varlistentry><term>PG-DB</term><listitem>
189 Database to connect to. Defaults to "template1" (which exists by default).
190 </listitem></varlistentry>
191  <!-- ==== -->
192  <varlistentry><term>PG-HOST</term><listitem>
193 Host to connect to. If it starts with "/" it will be interepreted as a directory
194 that holds the socket file. PostgreSQL defaults to /tmp.
195 </listitem></varlistentry>
196  <!-- ==== -->
197  <varlistentry><term>PG-MAX-WAL-WAIT</term><listitem>
198 <para>The maximum amount of time to wait for PG_STOP_BACKUP to archive a WAL
199 file.  In versions of PostgreSQL before 8.2, PG_STOP_BACKUP does not
200 automatically archive the latest WAL file, so a quiet database may
201 wait a very long time before archiving the WAL file.  Default: 60
202 seconds.  Set to 0 to wait forever.</para>
203 </listitem></varlistentry>
204  <!-- ==== -->
205  <varlistentry><term>PG-PASSFILE</term><listitem>
206 Connect using the creditials in this file. Each line should have the format
207 "hostname:port:database:username:password". The permissions must
208 permit it to be read only by the user, or the file will not be used.
209 Only usable with Postgres 8.1 and up.
210 </listitem></varlistentry>
211  <!-- ==== -->
212  <varlistentry><term>PG-PASSWORD</term><listitem>
213 Password to use when connecting. Deprecated in favor of passfiles.
214 </listitem></varlistentry>
215  <!-- ==== -->
216  <varlistentry><term>PG-PORT</term><listitem>
217 The TCP port to connect to, or the suffix of the socket file. PostgreSQL
218 defaults to 5432.
219 </listitem></varlistentry>
220  <!-- ==== -->
221  <varlistentry><term>PG-USER</term><listitem>
222 User to connect as. It must be a superuser.
223 </listitem></varlistentry>
224  <!-- ==== -->
225  <varlistentry><term>PSQL-PATH</term><listitem>
226 Path to the psql binary. If not specified, the PATH environment variable
227 will be searched.
228 </listitem></varlistentry>
229 </variablelist>
230
231 </refsect1>
232
233 <refsect1><title>RECOVERY</title>
234
235 <para>Read the postgres documentation carefully before attempting a recovery.
236 This section is only a rough guide to the process.</para>
237
238 <para>The data recovered from a postgres backup consists of a data tarball and
239 one or more archive tarballs.  The data contains the state of the database
240 at the time the full backup was performed, and the archive tarballs contain
241 postgres WAL files that must be re-run to generate a consistent
242 state.</para>
243
244 <para>Ensure that the database server is shut down, and move the existing data
245 directory aside.  Untar the data tarball over this directory, and verify
246 that ownership and permissions are correct.  Untar all of the archive
247 tarballs into a single directory - the archive directory.  Create a
248 <filename>recovery.conf</filename> in the data directory, owned by the
249 proper user and with proper permissions.  Add a
250 <command>restore_command</command> to it, e.g.,</para>
251
252 <programlisting>
253 restore_command = 'cp /path/to/archive_dir/%f "%p"'
254 </programlisting>
255
256 <para>Start the database server, and examine the logs to track the process of
257 the recovery.  When the recovery is complete, the server will transition
258 into a running state, and will move the <filename>recovery.conf</filename>
259 file aside so that it will not attempt a recovery on the next
260 invocation.</para>
261
262 </refsect1>
263
264 <seealso>
265 <manref name="amanda.conf" vol="5"/>,
266 <manref name="amanda-client.conf" vol="5"/>,
267 <manref name="amanda-applications" vol="7"/>
268 </seealso>
269
270
271 </refentry>