1PG_RECEIVEWAL(1) PostgreSQL 10.7 Documentation PG_RECEIVEWAL(1)
2
3
4
6 pg_receivewal - stream write-ahead logs from a PostgreSQL server
7
9 pg_receivewal [option...]
10
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.
26
27 The write-ahead log is streamed over a regular PostgreSQL connection
28 and uses the replication protocol. The connection must be made with a
29 superuser or a user having REPLICATION permissions (see Section 21.2),
30 and pg_hba.conf must permit the replication connection. The server must
31 also be configured with max_wal_senders set high enough to leave at
32 least one session available for the stream.
33
34 If the connection is lost, or if it cannot be initially established,
35 with a non-fatal error, pg_receivewal will retry the connection
36 indefinitely, and reestablish streaming as soon as possible. To avoid
37 this behavior, use the -n parameter.
38
40 -D directory
41 --directory=directory
42 Directory to write the output to.
43
44 This parameter is required.
45
46 --if-not-exists
47 Do not error out when --create-slot is specified and a slot with
48 the specified name already exists.
49
50 -n
51 --no-loop
52 Don't loop on connection errors. Instead, exit right away with an
53 error.
54
55 -s interval
56 --status-interval=interval
57 Specifies the number of seconds between status packets sent back to
58 the server. This allows for easier monitoring of the progress from
59 server. A value of zero disables the periodic status updates
60 completely, although an update will still be sent when requested by
61 the server, to avoid timeout disconnect. The default value is 10
62 seconds.
63
64 -S slotname
65 --slot=slotname
66 Require pg_receivewal to use an existing replication slot (see
67 Section 26.2.6). When this option is used, pg_receivewal will
68 report a flush position to the server, indicating when each segment
69 has been synchronized to disk so that the server can remove that
70 segment if it is not otherwise needed.
71
72 When the replication client of pg_receivewal is configured on the
73 server as a synchronous standby, then using a replication slot will
74 report the flush position to the server, but only when a WAL file
75 is closed. Therefore, that configuration will cause transactions on
76 the primary to wait for a long time and effectively not work
77 satisfactorily. The option --synchronous (see below) must be
78 specified in addition to make this work correctly.
79
80 --synchronous
81 Flush the WAL data to disk immediately after it has been received.
82 Also send a status packet back to the server immediately after
83 flushing, regardless of --status-interval.
84
85 This option should be specified if the replication client of
86 pg_receivewal is configured on the server as a synchronous standby,
87 to ensure that timely feedback is sent to the server.
88
89 -v
90 --verbose
91 Enables verbose mode.
92
93 -Z level
94 --compress=level
95 Enables gzip compression of write-ahead logs, and specifies the
96 compression level (0 through 9, 0 being no compression and 9 being
97 best compression). The suffix .gz will automatically be added to
98 all filenames.
99
100 The following command-line options control the database connection
101 parameters.
102
103 -d connstr
104 --dbname=connstr
105 Specifies parameters used to connect to the server, as a connection
106 string. See Section 33.1.1 for more information.
107
108 The option is called --dbname for consistency with other client
109 applications, but because pg_receivewal doesn't connect to any
110 particular database in the cluster, database name in the connection
111 string will be ignored.
112
113 -h host
114 --host=host
115 Specifies the host name of the machine on which the server is
116 running. If the value begins with a slash, it is used as the
117 directory for the Unix domain socket. The default is taken from the
118 PGHOST environment variable, if set, else a Unix domain socket
119 connection is attempted.
120
121 -p port
122 --port=port
123 Specifies the TCP port or local Unix domain socket file extension
124 on which the server is listening for connections. Defaults to the
125 PGPORT environment variable, if set, or a compiled-in default.
126
127 -U username
128 --username=username
129 User name to connect as.
130
131 -w
132 --no-password
133 Never issue a password prompt. If the server requires password
134 authentication and a password is not available by other means such
135 as a .pgpass file, the connection attempt will fail. This option
136 can be useful in batch jobs and scripts where no user is present to
137 enter a password.
138
139 -W
140 --password
141 Force pg_receivewal to prompt for a password before connecting to a
142 database.
143
144 This option is never essential, since pg_receivewal will
145 automatically prompt for a password if the server demands password
146 authentication. However, pg_receivewal will waste a connection
147 attempt finding out that the server wants a password. In some cases
148 it is worth typing -W to avoid the extra connection attempt.
149
150 pg_receivewal can perform one of the two following actions in order to
151 control physical replication slots:
152
153 --create-slot
154 Create a new physical replication slot with the name specified in
155 --slot, then exit.
156
157 --drop-slot
158 Drop the replication slot with the name specified in --slot, then
159 exit.
160
161 Other options are also available:
162
163 -V
164 --version
165 Print the pg_receivewal version and exit.
166
167 -?
168 --help
169 Show help about pg_receivewal command line arguments, and exit.
170
172 This utility, like most other PostgreSQL utilities, uses the
173 environment variables supported by libpq (see Section 33.14).
174
176 When using pg_receivewal instead of archive_command as the main WAL
177 backup method, it is strongly recommended to use replication slots.
178 Otherwise, the server is free to recycle or remove write-ahead log
179 files before they are backed up, because it does not have any
180 information, either from archive_command or the replication slots,
181 about how far the WAL stream has been archived. Note, however, that a
182 replication slot will fill up the server's disk space if the receiver
183 does not keep up with fetching the WAL data.
184
186 To stream the write-ahead log from the server at mydbserver and store
187 it in the local directory /usr/local/pgsql/archive:
188
189 $ pg_receivewal -h mydbserver -D /usr/local/pgsql/archive
190
192 pg_basebackup(1)
193
194
195
196PostgreSQL 10.7 2019 PG_RECEIVEWAL(1)