1PG_RECEIVEWAL(1)         PostgreSQL 12.2 Documentation        PG_RECEIVEWAL(1)
2
3
4

NAME

6       pg_receivewal - stream write-ahead logs from a PostgreSQL server
7

SYNOPSIS

9       pg_receivewal [option...]
10

DESCRIPTION

12       pg_receivewal is used to stream the write-ahead log from a running
13       PostgreSQL cluster. The write-ahead log is streamed using the streaming
14       replication protocol, and is written to a local directory of files.
15       This directory can be used as the archive location for doing a restore
16       using point-in-time recovery (see Section 25.3).
17
18       pg_receivewal streams the write-ahead log in real time as it's being
19       generated on the server, and does not wait for segments to complete
20       like archive_command does. For this reason, it is not necessary to set
21       archive_timeout when using pg_receivewal.
22
23       Unlike the WAL receiver of a PostgreSQL standby server, pg_receivewal
24       by default flushes WAL data only when a WAL file is closed. The option
25       --synchronous must be specified to flush WAL data in real time. Since
26       pg_receivewal does not apply WAL, you should not allow it to become a
27       synchronous standby when synchronous_commit equals remote_apply. If it
28       does, it will appear to be a standby that never catches up, and will
29       cause transaction commits to block. To avoid this, you should either
30       configure an appropriate value for synchronous_standby_names, or
31       specify application_name for pg_receivewal that does not match it, or
32       change the value of synchronous_commit to something other than
33       remote_apply.
34
35       The write-ahead log is streamed over a regular PostgreSQL connection
36       and uses the replication protocol. The connection must be made with a
37       superuser or a user having REPLICATION permissions (see Section 21.2),
38       and pg_hba.conf must permit the replication connection. The server must
39       also be configured with max_wal_senders set high enough to leave at
40       least one session available for the stream.
41
42       If the connection is lost, or if it cannot be initially established,
43       with a non-fatal error, pg_receivewal will retry the connection
44       indefinitely, and reestablish streaming as soon as possible. To avoid
45       this behavior, use the -n parameter.
46
47       In the absence of fatal errors, pg_receivewal will run until terminated
48       by the SIGINT signal (Control+C).
49

OPTIONS

51       -D directory
52       --directory=directory
53           Directory to write the output to.
54
55           This parameter is required.
56
57       -E lsn
58       --endpos=lsn
59           Automatically stop replication and exit with normal exit status 0
60           when receiving reaches the specified LSN.
61
62           If there is a record with LSN exactly equal to lsn, the record will
63           be processed.
64
65       --if-not-exists
66           Do not error out when --create-slot is specified and a slot with
67           the specified name already exists.
68
69       -n
70       --no-loop
71           Don't loop on connection errors. Instead, exit right away with an
72           error.
73
74       --no-sync
75           This option causes pg_receivewal to not force WAL data to be
76           flushed to disk. This is faster, but means that a subsequent
77           operating system crash can leave the WAL segments corrupt.
78           Generally, this option is useful for testing but should not be used
79           when doing WAL archiving on a production deployment.
80
81           This option is incompatible with --synchronous.
82
83       -s interval
84       --status-interval=interval
85           Specifies the number of seconds between status packets sent back to
86           the server. This allows for easier monitoring of the progress from
87           server. A value of zero disables the periodic status updates
88           completely, although an update will still be sent when requested by
89           the server, to avoid timeout disconnect. The default value is 10
90           seconds.
91
92       -S slotname
93       --slot=slotname
94           Require pg_receivewal to use an existing replication slot (see
95           Section 26.2.6). When this option is used, pg_receivewal will
96           report a flush position to the server, indicating when each segment
97           has been synchronized to disk so that the server can remove that
98           segment if it is not otherwise needed.
99
100           When the replication client of pg_receivewal is configured on the
101           server as a synchronous standby, then using a replication slot will
102           report the flush position to the server, but only when a WAL file
103           is closed. Therefore, that configuration will cause transactions on
104           the primary to wait for a long time and effectively not work
105           satisfactorily. The option --synchronous (see below) must be
106           specified in addition to make this work correctly.
107
108       --synchronous
109           Flush the WAL data to disk immediately after it has been received.
110           Also send a status packet back to the server immediately after
111           flushing, regardless of --status-interval.
112
113           This option should be specified if the replication client of
114           pg_receivewal is configured on the server as a synchronous standby,
115           to ensure that timely feedback is sent to the server.
116
117       -v
118       --verbose
119           Enables verbose mode.
120
121       -Z level
122       --compress=level
123           Enables gzip compression of write-ahead logs, and specifies the
124           compression level (0 through 9, 0 being no compression and 9 being
125           best compression). The suffix .gz will automatically be added to
126           all filenames.
127
128       The following command-line options control the database connection
129       parameters.
130
131       -d connstr
132       --dbname=connstr
133           Specifies parameters used to connect to the server, as a connection
134           string. See Section 33.1.1 for more information.
135
136           The option is called --dbname for consistency with other client
137           applications, but because pg_receivewal doesn't connect to any
138           particular database in the cluster, database name in the connection
139           string will be ignored.
140
141       -h host
142       --host=host
143           Specifies the host name of the machine on which the server is
144           running. If the value begins with a slash, it is used as the
145           directory for the Unix domain socket. The default is taken from the
146           PGHOST environment variable, if set, else a Unix domain socket
147           connection is attempted.
148
149       -p port
150       --port=port
151           Specifies the TCP port or local Unix domain socket file extension
152           on which the server is listening for connections. Defaults to the
153           PGPORT environment variable, if set, or a compiled-in default.
154
155       -U username
156       --username=username
157           User name to connect as.
158
159       -w
160       --no-password
161           Never issue a password prompt. If the server requires password
162           authentication and a password is not available by other means such
163           as a .pgpass file, the connection attempt will fail. This option
164           can be useful in batch jobs and scripts where no user is present to
165           enter a password.
166
167       -W
168       --password
169           Force pg_receivewal to prompt for a password before connecting to a
170           database.
171
172           This option is never essential, since pg_receivewal will
173           automatically prompt for a password if the server demands password
174           authentication. However, pg_receivewal will waste a connection
175           attempt finding out that the server wants a password. In some cases
176           it is worth typing -W to avoid the extra connection attempt.
177
178       pg_receivewal can perform one of the two following actions in order to
179       control physical replication slots:
180
181       --create-slot
182           Create a new physical replication slot with the name specified in
183           --slot, then exit.
184
185       --drop-slot
186           Drop the replication slot with the name specified in --slot, then
187           exit.
188
189       Other options are also available:
190
191       -V
192       --version
193           Print the pg_receivewal version and exit.
194
195       -?
196       --help
197           Show help about pg_receivewal command line arguments, and exit.
198

EXIT STATUS

200       pg_receivewal will exit with status 0 when terminated by the SIGINT
201       signal. (That is the normal way to end it. Hence it is not an error.)
202       For fatal errors or other signals, the exit status will be nonzero.
203

ENVIRONMENT

205       This utility, like most other PostgreSQL utilities, uses the
206       environment variables supported by libpq (see Section 33.14).
207
208       The environment variable PG_COLOR specifies whether to use color in
209       diagnostics messages. Possible values are always, auto, never.
210

NOTES

212       When using pg_receivewal instead of archive_command as the main WAL
213       backup method, it is strongly recommended to use replication slots.
214       Otherwise, the server is free to recycle or remove write-ahead log
215       files before they are backed up, because it does not have any
216       information, either from archive_command or the replication slots,
217       about how far the WAL stream has been archived. Note, however, that a
218       replication slot will fill up the server's disk space if the receiver
219       does not keep up with fetching the WAL data.
220
221       pg_receivewal will preserve group permissions on the received WAL files
222       if group permissions are enabled on the source cluster.
223

EXAMPLES

225       To stream the write-ahead log from the server at mydbserver and store
226       it in the local directory /usr/local/pgsql/archive:
227
228           $ pg_receivewal -h mydbserver -D /usr/local/pgsql/archive
229

SEE ALSO

231       pg_basebackup(1)
232
233
234
235PostgreSQL 12.2                      2020                     PG_RECEIVEWAL(1)
Impressum