Imported Upstream version 3.2.0
[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>DIRECTORY</term><listitem>
78 For restore command only, the data is recoved in that directory. Must be a unix path.
79 </listitem></varlistentry>
80
81  <!-- ==== -->
82  <varlistentry><term>GNUTAR-PATH</term><listitem>
83 Path to the GNU tar executable. This option only has an effect during restore.
84 The default is set when Amanda is built by the --with-gnutar configure option.
85 </listitem></varlistentry>
86  <!-- ==== -->
87  <varlistentry><term>STATEDIR</term><listitem>
88 Directory for saving state about backups already made. The default is set
89 when Amanda is built by the --with-gnutar-listdir configure option.
90 </listitem></varlistentry>
91  <!-- ==== -->
92  <varlistentry><term>TMPDIR</term><listitem>
93 Directory to use for temporary files during the backup process. It should
94 have enough space to store a complete copy of the database. The default is set
95 when Amanda is built by the --with-tmpdir configure option.
96 </listitem></varlistentry>
97
98 </variablelist>
99
100 </refsect1>
101
102 <refsect1><title>CLIENT PROPERTIES</title>
103
104 <para>This section lists the <manref name="amanda-client.conf" vol="5"/> properties that control ampsql's functionality.
105 If a property is prefixed with the diskname and an underscore,
106 then it will be used when that diskname is being backed up.
107 For example, if the properties PG-DATADIR and foo-PG-DATADIR are set,
108 the value of PG-DATADIR will be used when bar and baz are being backed up,
109 but foo-PG-DATADIR will be used when foo is being backed up.
110 Disknames are specified in the <manref name="disklist" vol="5"/>.
111 </para>
112
113 <!-- PLEASE KEEP THIS LIST IN ALPHABETICAL ORDER -->
114 <variablelist>
115  <!-- ==== -->
116  <varlistentry><term>PG-ARCHIVEDIR</term><listitem>
117 Directory that WAL segment files are archived to, as specified by the archive_command
118 in PosgreSQL's postgresql.conf.  The amanda user on the client must have at least read
119 and execute permission on this directory, and preferably write.  Without write permission,
120 Amanda cannot clean up expired WAL and backup files.
121 </listitem></varlistentry>
122  <!-- ==== -->
123  <varlistentry><term>PG-CLEANUPWAL</term><listitem>
124 Whether or not to remove old WAL segment files during base backups.
125 Defaults to yes.
126 </listitem></varlistentry>
127  <!-- ==== -->
128  <varlistentry><term>PG-DATADIR</term><listitem>
129 Cluster data directory
130 </listitem></varlistentry>
131  <!-- ==== -->
132  <varlistentry><term>PG-DB</term><listitem>
133 Database to connect to. Defaults to "template1" (which exists by default).
134 </listitem></varlistentry>
135  <!-- ==== -->
136  <varlistentry><term>PG-HOST</term><listitem>
137 Host to connect to. If it starts with "/" it will be interepreted as a directory
138 that holds the socket file. PostgreSQL defaults to /tmp.
139 </listitem></varlistentry>
140  <!-- ==== -->
141  <varlistentry><term>PG-MAX-WAL-WAIT</term><listitem>
142 <para>The maximum amount of time to wait for PG_STOP_BACKUP to archive a WAL
143 file.  In versions of PostgreSQL before 8.2, PG_STOP_BACKUP does not
144 automatically archive the latest WAL file, so a quiet database may
145 wait a very long time before archiving the WAL file.  Default: 60
146 seconds.  Set to 0 to wait forever.</para>
147 </listitem></varlistentry>
148  <!-- ==== -->
149  <varlistentry><term>PG-PASSFILE</term><listitem>
150 Connect using the creditials in this file. Each line should have the format
151 "hostname:port:database:username:password". The permissions must
152 permit it to be read only by the user, or the file will not be used.
153 Only usable with Postgres 8.1 and up.
154 </listitem></varlistentry>
155  <!-- ==== -->
156  <varlistentry><term>PG-PASSWORD</term><listitem>
157 Password to use when connecting. Deprecated in favor of passfiles.
158 </listitem></varlistentry>
159  <!-- ==== -->
160  <varlistentry><term>PG-PORT</term><listitem>
161 The TCP port to connect to, or the suffix of the socket file. PostgreSQL
162 defaults to 5432.
163 </listitem></varlistentry>
164  <!-- ==== -->
165  <varlistentry><term>PG-USER</term><listitem>
166 User to connect as. It must be a superuser.
167 </listitem></varlistentry>
168  <!-- ==== -->
169  <varlistentry><term>PSQL-PATH</term><listitem>
170 Path to the psql binary. If not specified, the PATH environment variable
171 will be searched.
172 </listitem></varlistentry>
173 </variablelist>
174
175 </refsect1>
176
177 <refsect1><title>RECOVERY</title>
178
179 <para>Read the postgres documentation carefully before attempting a recovery.
180 This section is only a rough guide to the process.</para>
181
182 <para>The data recovered from a postgres backup consists of a data tarball and
183 one or more archive tarballs.  The data contains the state of the database
184 at the time the full backup was performed, and the archive tarballs contain
185 postgres WAL files that must be re-run to generate a consistent
186 state.</para>
187
188 <para>Ensure that the database server is shut down, and move the existing data
189 directory aside.  Untar the data tarball over this directory, and verify
190 that ownership and permissions are correct.  Untar all of the archive
191 tarballs into a single directory - the archive directory.  Create a
192 <filename>recovery.conf</filename> in the data directory, owned by the
193 proper user and with proper permissions.  Add a
194 <command>restore_command</command> to it, e.g.,</para>
195
196 <programlisting>
197 restore_command = 'cp /path/to/archive_dir/%f "%p"'
198 </programlisting>
199
200 <para>Start the database server, and examine the logs to track the process of
201 the recovery.  When the recovery is complete, the server will transition
202 into a running state, and will move the <filename>recovery.conf</filename>
203 file aside so that it will not attempt a recovery on the next
204 invocation.</para>
205
206 </refsect1>
207
208 <seealso>
209 <manref name="amanda.conf" vol="5"/>,
210 <manref name="amanda-client.conf" vol="5"/>,
211 <manref name="amanda-applications" vol="7"/>
212 </seealso>
213
214
215 </refentry>