2 doc/src/sgml/ref/pg_receivexlog.sgml
3 PostgreSQL documentation
6 <refentry id="app-pgreceivexlog">
8 <refentrytitle>pg_receivexlog</refentrytitle>
9 <manvolnum>1</manvolnum>
10 <refmiscinfo>Application</refmiscinfo>
14 <refname>pg_receivexlog</refname>
15 <refpurpose>streams transaction logs from a <productname>PostgreSQL</productname> cluster</refpurpose>
18 <indexterm zone="app-pgreceivexlog">
19 <primary>pg_receivexlog</primary>
24 <command>pg_receivexlog</command>
25 <arg rep="repeat"><replaceable>option</></arg>
34 <application>pg_receivexlog</application> is used to stream transaction log
35 from a running <productname>PostgreSQL</productname> cluster. The transaction
36 log is streamed using the streaming replication protocol, and is written
37 to a local directory of files. This directory can be used as the archive
38 location for doing a restore using point-in-time recovery (see
39 <xref linkend="continuous-archiving">).
43 <application>pg_receivexlog</application> streams the transaction
44 log in real time as it's being generated on the server, and does not wait
45 for segments to complete like <xref linkend="guc-archive-command"> does.
46 For this reason, it is not necessary to set
47 <xref linkend="guc-archive-timeout"> when using
48 <application>pg_receivexlog</application>.
52 The transaction log is streamed over a regular
53 <productname>PostgreSQL</productname> connection, and uses the
54 replication protocol. The connection must be
55 made with a user having <literal>REPLICATION</literal> permissions (see
56 <xref linkend="role-attributes">), and the user must be granted explicit
57 permissions in <filename>pg_hba.conf</filename>. The server must also
58 be configured with <xref linkend="guc-max-wal-senders"> set high enough
59 to leave at least one session available for the stream.
64 <title>Options</title>
67 The following command-line options control the location and format of the
72 <term><option>-D <replaceable class="parameter">directory</replaceable></option></term>
73 <term><option>--dir=<replaceable class="parameter">directory</replaceable></option></term>
76 Directory to write the output to.
79 This parameter is required.
86 The following command-line options control the running of the program.
90 <term><option>-v</option></term>
91 <term><option>--verbose</option></term>
103 The following command-line options control the database connection parameters.
107 <term><option>-s <replaceable class="parameter">interval</replaceable></option></term>
108 <term><option>--statusint=<replaceable class="parameter">interval</replaceable></option></term>
111 Specifies the number of seconds between status packets sent back to the
112 server. This is required if replication timeout is configured on the
113 server, and allows for easier monitoring. The default value is
120 <term><option>-h <replaceable class="parameter">host</replaceable></option></term>
121 <term><option>--host=<replaceable class="parameter">host</replaceable></option></term>
124 Specifies the host name of the machine on which the server is
125 running. If the value begins with a slash, it is used as the
126 directory for the Unix domain socket. The default is taken
127 from the <envar>PGHOST</envar> environment variable, if set,
128 else a Unix domain socket connection is attempted.
134 <term><option>-p <replaceable class="parameter">port</replaceable></option></term>
135 <term><option>--port=<replaceable class="parameter">port</replaceable></option></term>
138 Specifies the TCP port or local Unix domain socket file
139 extension on which the server is listening for connections.
140 Defaults to the <envar>PGPORT</envar> environment variable, if
141 set, or a compiled-in default.
147 <term><option>-U <replaceable>username</replaceable></option></term>
148 <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
151 User name to connect as.
157 <term><option>-w</></term>
158 <term><option>--no-password</></term>
161 Never issue a password prompt. If the server requires
162 password authentication and a password is not available by
163 other means such as a <filename>.pgpass</filename> file, the
164 connection attempt will fail. This option can be useful in
165 batch jobs and scripts where no user is present to enter a
172 <term><option>-W</option></term>
173 <term><option>--password</option></term>
176 Force <application>pg_receivexlog</application> to prompt for a
177 password before connecting to a database.
181 This option is never essential, since
182 <application>pg_receivexlog</application> will automatically prompt
183 for a password if the server demands password authentication.
184 However, <application>pg_receivexlog</application> will waste a
185 connection attempt finding out that the server wants a password.
186 In some cases it is worth typing <option>-W</> to avoid the extra
195 Other, less commonly used, parameters are also available:
199 <term><option>-V</></term>
200 <term><option>--version</></term>
203 Print the <application>pg_receivexlog</application> version and exit.
209 <term><option>-?</></term>
210 <term><option>--help</></term>
213 Show help about <application>pg_receivexlog</application> command line
225 <title>Environment</title>
228 This utility, like most other <productname>PostgreSQL</> utilities,
229 uses the environment variables supported by <application>libpq</>
230 (see <xref linkend="libpq-envars">).
239 When using <application>pg_receivexlog</application> instead of
240 <xref linkend="guc-archive-command">, the server will continue to
241 recycle transaction log files even if the backups are not properly
242 archived, since there is no command that fails. This can be worked
243 around by having an <xref linkend="guc-archive-command"> that fails
244 when the file has not been properly archived yet.
250 <title>Examples</title>
253 To stream the transaction log from the server at
254 <literal>mydbserver</literal> and store it in the local directory
255 <filename>/usr/local/pgsql/archive</filename>:
257 <prompt>$</prompt> <userinput>pg_receivexlog -h mydbserver -D /home/pgbackup/archive</userinput>
263 <title>See Also</title>
265 <simplelist type="inline">
266 <member><xref linkend="APP-PGBASEBACKUP"></member>