{"Entry":{"collection":"tool","key":"pg-receivewal","name":"pg_receivewal","aliases":["pg_receivewal"],"metadata":{"aliases":["pg_receivewal"],"category":"Client applications","content_hash":"24fd837878b5828329dd5dabe482f7eedbf928f3954a5a5e0bef8793533886af","imported_at":"2026-09-30T00:40:34.308286+08:00","name":"pg_receivewal","name_zh":"","slug":"pg-receivewal","summary":"pg_receivewal — stream write-ahead logs from a PostgreSQL server"}},"Definition":{"Collection":"tool","Key":"pg-receivewal","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"pg-receivewal","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"environment":[],"options":[{"description":"Directory to write the output to. This parameter is required.","names":["-D directory","--directory= directory"],"signature":"-D directory --directory= directory"},{"description":"Automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN. If there is a record with LSN exactly equal to lsn , the record will be processed.","names":["-E lsn","--endpos= lsn"],"signature":"-E lsn --endpos= lsn"},{"description":"Do not error out when --create-slot is specified and a slot with the specified name already exists.","names":["--if-not-exists"],"signature":"--if-not-exists"},{"description":"Don't loop on connection errors. Instead, exit right away with an error.","names":["-n","--no-loop"],"signature":"-n --no-loop"},{"description":"This option causes pg_receivewal to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment. This option is incompatible with --synchronous .","names":["--no-sync"],"signature":"--no-sync"},{"description":"Specifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds.","names":["-s interval","--status-interval= interval"],"signature":"-s interval --status-interval= interval"},{"description":"Require pg_receivewal to use an existing replication slot (see Section 26.2.6 ). When this option is used, pg_receivewal will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed. When the replication client of pg_receivewal is configured on the server as a synchronous standby, then using a replication slot will report the flush position to the server, but only when a WAL file is closed. Therefore, that configuration will cause transactions on the primary to wait for a long time and effectively not work satisfactorily. The option --synchronous (see below) must be specified in addition to make this work correctly.","names":["-S slotname","--slot= slotname"],"signature":"-S slotname --slot= slotname"},{"description":"Flush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of --status-interval . This option should be specified if the replication client of pg_receivewal is configured on the server as a synchronous standby, to ensure that timely feedback is sent to the server.","names":["--synchronous"],"signature":"--synchronous"},{"description":"Enables verbose mode.","names":["-v","--verbose"],"signature":"-v --verbose"},{"description":"Enables compression of write-ahead logs. The compression method can be set to gzip , lz4 (if PostgreSQL was compiled with --with-lz4 ) or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the only supported keyword is level . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0, and no compression will be used if the level is 0. The suffix .gz will automatically be added to all filenames when using gzip , and the suffix .lz4 is added when using lz4 .","names":["-Z level","-Z method [: detail ]","--compress= level","--compress= method [: detail ]"],"signature":"-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]"},{"description":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options. This option is called --dbname for consistency with other client applications, but because pg_receivewal doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name ( replication ) for purposes of looking up the replication connection's password in ~/.pgpass . Similarly, middleware or proxies used in connecting to PostgreSQL might utilize the name for purposes such as connection routing.","names":["-d connstr","--dbname= connstr"],"signature":"-d connstr --dbname= connstr"},{"description":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted.","names":["-h host","--host= host"],"signature":"-h host --host= host"},{"description":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default.","names":["-p port","--port= port"],"signature":"-p port --port= port"},{"description":"User name to connect as.","names":["-U username","--username= username"],"signature":"-U username --username= username"},{"description":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.","names":["-w","--no-password"],"signature":"-w --no-password"},{"description":"Force pg_receivewal to prompt for a password before connecting to a database. This option is never essential, since pg_receivewal will automatically prompt for a password if the server demands password authentication. However, pg_receivewal will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.","names":["-W","--password"],"signature":"-W --password"},{"description":"Create a new physical replication slot with the name specified in --slot , then exit.","names":["--create-slot"],"signature":"--create-slot"},{"description":"Drop the replication slot with the name specified in --slot , then exit.","names":["--drop-slot"],"signature":"--drop-slot"},{"description":"Print the pg_receivewal version and exit.","names":["-V","--version"],"signature":"-V --version"},{"description":"Show help about pg_receivewal command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help"}],"synopsis":["pg_receivewal [ option ...]"]},"comparison_hash":"c6606e42cd220bb7a9951062dfe3243fa8a486a49301db7c5ead2d5dd84a85fc","description":["pg_receivewal — stream write-ahead logs from a PostgreSQL server"],"environment":[],"facts":[{"label":"Documented executable","value":"pg_receivewal"},{"label":"Executable version","value":"18.6"},{"label":"Reference inventory","value":"Client applications"},{"label":"Option definition groups","value":"20"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGRECEIVEWAL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_receivewal — stream write-ahead logs from a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.17.4.1\"\u003e\u003ccode class=\"command\"\u003epg_receivewal\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e is used to stream the write-ahead log from a running \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e cluster. The write-ahead log is streamed using the streaming replication protocol, and is written to a local directory of files. This directory can be used as the archive location for doing a restore using point-in-time recovery (see \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html\" title=\"25.3. Continuous Archiving and Point-in-Time Recovery (PITR)\"\u003eSection 25.3\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e streams the write-ahead log in real time as it's being generated on the server, and does not wait for segments to complete like \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e and \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e do. For this reason, it is not necessary to set \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT\"\u003earchive_timeout\u003c/a\u003e when using \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eUnlike the WAL receiver of a PostgreSQL standby server, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e by default flushes WAL data only when a WAL file is closed. The option \u003ccode class=\"option\"\u003e--synchronous\u003c/code\u003e must be specified to flush WAL data in real time. Since \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e does not apply WAL, you should not allow it to become a synchronous standby when \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT\"\u003esynchronous_commit\u003c/a\u003e equals \u003ccode class=\"literal\"\u003eremote_apply\u003c/code\u003e. If it does, it will appear to be a standby that never catches up, and will cause transaction commits to block. To avoid this, you should either configure an appropriate value for \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES\"\u003esynchronous_standby_names\u003c/a\u003e, or specify \u003ccode class=\"varname\"\u003eapplication_name\u003c/code\u003e for \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e that does not match it, or change the value of \u003ccode class=\"varname\"\u003esynchronous_commit\u003c/code\u003e to something other than \u003ccode class=\"literal\"\u003eremote_apply\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe write-ahead log is streamed over a regular \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e connection and uses the replication protocol. The connection must be made with a user having \u003ccode class=\"literal\"\u003eREPLICATION\u003c/code\u003e permissions (see \u003ca class=\"xref\" href=\"/docs/18/role-attributes.html\" title=\"21.2. Role Attributes\"\u003eSection 21.2\u003c/a\u003e) or a superuser, and \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e must permit the replication connection. The server must also be configured with \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-MAX-WAL-SENDERS\"\u003emax_wal_senders\u003c/a\u003e set high enough to leave at least one session available for the stream.\u003c/p\u003e\n\u003cp\u003eThe starting point of the write-ahead log streaming is calculated when \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e starts:\u003c/p\u003e\n\u003cdiv class=\"orderedlist\"\u003e\n\u003col class=\"orderedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eFirst, scan the directory where the WAL segment files are written and find the newest completed segment file, using as the starting point the beginning of the next WAL segment file.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf a starting point cannot be calculated with the previous method, and if a replication slot is used, an extra \u003ccode class=\"command\"\u003eREAD_REPLICATION_SLOT\u003c/code\u003e command is issued to retrieve the slot's \u003ccode class=\"literal\"\u003erestart_lsn\u003c/code\u003e to use as the starting point. This option is only available when streaming write-ahead logs from \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 15 and up.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf a starting point cannot be calculated with the previous method, the latest WAL flush location is used as reported by the server from an \u003ccode class=\"literal\"\u003eIDENTIFY_SYSTEM\u003c/code\u003e command.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/div\u003e\n\u003cp\u003eIf the connection is lost, or if it cannot be initially established, with a non-fatal error, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will retry the connection indefinitely, and reestablish streaming as soon as possible. To avoid this behavior, use the \u003ccode class=\"literal\"\u003e-n\u003c/code\u003e parameter.\u003c/p\u003e\n\u003cp\u003eIn the absence of fatal errors, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will run until terminated by the \u003cspan class=\"systemitem\"\u003eSIGINT\u003c/span\u003e (\u003cspan class=\"keycap\"\u003e\u003cstrong\u003eControl\u003c/strong\u003e\u003c/span\u003e+\u003cspan class=\"keycap\"\u003e\u003cstrong\u003eC\u003c/strong\u003e\u003c/span\u003e) or \u003cspan class=\"systemitem\"\u003eSIGTERM\u003c/span\u003e signal.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--directory=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDirectory to write the output to.\u003c/p\u003e\n\u003cp\u003eThis parameter is required.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-E \u003cem class=\"replaceable\"\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--endpos=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAutomatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN.\u003c/p\u003e\n\u003cp\u003eIf there is a record with LSN exactly equal to \u003cem class=\"replaceable\"\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e, the record will be processed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-not-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not error out when \u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e is specified and a slot with the specified name already exists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-loop\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDon't loop on connection errors. Instead, exit right away with an error.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option causes \u003ccode class=\"command\"\u003epg_receivewal\u003c/code\u003e to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment.\u003c/p\u003e\n\u003cp\u003eThis option is incompatible with \u003ccode class=\"literal\"\u003e--synchronous\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s \u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--status-interval=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--slot=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequire \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e to use an existing replication slot (see \u003ca class=\"xref\" href=\"/docs/18/warm-standby.html#STREAMING-REPLICATION-SLOTS\" title=\"26.2.6. Replication Slots\"\u003eSection 26.2.6\u003c/a\u003e). When this option is used, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed.\u003c/p\u003e\n\u003cp\u003eWhen the replication client of \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e is configured on the server as a synchronous standby, then using a replication slot will report the flush position to the server, but only when a WAL file is closed. Therefore, that configuration will cause transactions on the primary to wait for a long time and effectively not work satisfactorily. The option \u003ccode class=\"literal\"\u003e--synchronous\u003c/code\u003e (see below) must be specified in addition to make this work correctly.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--synchronous\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eFlush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of \u003ccode class=\"literal\"\u003e--status-interval\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option should be specified if the replication client of \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e is configured on the server as a synchronous standby, to ensure that timely feedback is sent to the server.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables verbose mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z \u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z \u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables compression of write-ahead logs.\u003c/p\u003e\n\u003cp\u003eThe compression method can be set to \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e (if \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e was compiled with \u003ccode class=\"option\"\u003e--with-lz4\u003c/code\u003e) or \u003ccode class=\"literal\"\u003enone\u003c/code\u003e for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword\u003c/code\u003e\u003c/em\u003e or \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword=value\u003c/code\u003e\u003c/em\u003e. Currently, the only supported keyword is \u003ccode class=\"literal\"\u003elevel\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e compression will be used if the level is greater than 0, and no compression will be used if the level is 0.\u003c/p\u003e\n\u003cp\u003eThe suffix \u003ccode class=\"filename\"\u003e.gz\u003c/code\u003e will automatically be added to all filenames when using \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, and the suffix \u003ccode class=\"filename\"\u003e.lz4\u003c/code\u003e is added when using \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the database connection parameters.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies parameters used to connect to the server, as a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e; these will override any conflicting command line options.\u003c/p\u003e\n\u003cp\u003eThis option is called \u003ccode class=\"literal\"\u003e--dbname\u003c/code\u003e for consistency with other client applications, but because \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name (\u003ccode class=\"literal\"\u003ereplication\u003c/code\u003e) for purposes of looking up the replication connection's password in \u003ccode class=\"filename\"\u003e~/.pgpass\u003c/code\u003e. Similarly, middleware or proxies used in connecting to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e might utilize the name for purposes such as connection routing.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUser name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e to prompt for a password before connecting to a database.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e can perform one of the two following actions in order to control physical replication slots:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a new physical replication slot with the name specified in \u003ccode class=\"option\"\u003e--slot\u003c/code\u003e, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--drop-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDrop the replication slot with the name specified in \u003ccode class=\"option\"\u003e--slot\u003c/code\u003e, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options are also available:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will exit with status 0 when terminated by the \u003cspan class=\"systemitem\"\u003eSIGINT\u003c/span\u003e or \u003cspan class=\"systemitem\"\u003eSIGTERM\u003c/span\u003e signal. (That is the normal way to end it. Hence it is not an error.) For fatal errors or other signals, the exit status will be nonzero.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.8\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.9\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eWhen using \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e instead of \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e or \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e as the main WAL backup method, it is strongly recommended to use replication slots. Otherwise, the server is free to recycle or remove write-ahead log files before they are backed up, because it does not have any information, either from \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e or \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e or the replication slots, about how far the WAL stream has been archived. Note, however, that a replication slot will fill up the server's disk space if the receiver does not keep up with fetching the WAL data.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will preserve group permissions on the received WAL files if group permissions are enabled on the source cluster.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.10\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eTo stream the write-ahead log from the server at \u003ccode class=\"literal\"\u003emydbserver\u003c/code\u003e and store it in the local directory \u003ccode class=\"filename\"\u003e/usr/local/pgsql/archive\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_receivewal -h mydbserver -D /usr/local/pgsql/archive\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.11\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgbasebackup.html\" title=\"pg_basebackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","manual_path":"app-pgreceivewal.html","options":[{"description":"Directory to write the output to. This parameter is required.","names":["-D directory","--directory= directory"],"signature":"-D directory --directory= directory","source_url":"/docs/18/app-pgreceivewal.html","summary":"Directory to write the output to."},{"description":"Automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN. If there is a record with LSN exactly equal to lsn , the record will be processed.","names":["-E lsn","--endpos= lsn"],"signature":"-E lsn --endpos= lsn","source_url":"/docs/18/app-pgreceivewal.html","summary":"Automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN."},{"description":"Do not error out when --create-slot is specified and a slot with the specified name already exists.","names":["--if-not-exists"],"signature":"--if-not-exists","source_url":"/docs/18/app-pgreceivewal.html","summary":"Do not error out when --create-slot is specified and a slot with the specified name already exists."},{"description":"Don't loop on connection errors. Instead, exit right away with an error.","names":["-n","--no-loop"],"signature":"-n --no-loop","source_url":"/docs/18/app-pgreceivewal.html","summary":"Don't loop on connection errors. Instead, exit right away with an error."},{"description":"This option causes pg_receivewal to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment. This option is incompatible with --synchronous .","names":["--no-sync"],"signature":"--no-sync","source_url":"/docs/18/app-pgreceivewal.html","summary":"This option causes pg_receivewal to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment."},{"description":"Specifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds.","names":["-s interval","--status-interval= interval"],"signature":"-s interval --status-interval= interval","source_url":"/docs/18/app-pgreceivewal.html","summary":"Specifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds."},{"description":"Require pg_receivewal to use an existing replication slot (see Section 26.2.6 ). When this option is used, pg_receivewal will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed. When the replication client of pg_receivewal is configured on the server as a synchronous standby, then using a replication slot will report the flush position to the server, but only when a WAL file is closed. Therefore, that configuration will cause transactions on the primary to wait for a long time and effectively not work satisfactorily. The option --synchronous (see below) must be specified in addition to make this work correctly.","names":["-S slotname","--slot= slotname"],"signature":"-S slotname --slot= slotname","source_url":"/docs/18/app-pgreceivewal.html","summary":"Require pg_receivewal to use an existing replication slot (see Section 26.2.6 ). When this option is used, pg_receivewal will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed."},{"description":"Flush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of --status-interval . This option should be specified if the replication client of pg_receivewal is configured on the server as a synchronous standby, to ensure that timely feedback is sent to the server.","names":["--synchronous"],"signature":"--synchronous","source_url":"/docs/18/app-pgreceivewal.html","summary":"Flush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of --status-interval ."},{"description":"Enables verbose mode.","names":["-v","--verbose"],"signature":"-v --verbose","source_url":"/docs/18/app-pgreceivewal.html","summary":"Enables verbose mode."},{"description":"Enables compression of write-ahead logs. The compression method can be set to gzip , lz4 (if PostgreSQL was compiled with --with-lz4 ) or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the only supported keyword is level . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0, and no compression will be used if the level is 0. The suffix .gz will automatically be added to all filenames when using gzip , and the suffix .lz4 is added when using lz4 .","names":["-Z level","-Z method [: detail ]","--compress= level","--compress= method [: detail ]"],"signature":"-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]","source_url":"/docs/18/app-pgreceivewal.html","summary":"Enables compression of write-ahead logs."},{"description":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options. This option is called --dbname for consistency with other client applications, but because pg_receivewal doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name ( replication ) for purposes of looking up the replication connection's password in ~/.pgpass . Similarly, middleware or proxies used in connecting to PostgreSQL might utilize the name for purposes such as connection routing.","names":["-d connstr","--dbname= connstr"],"signature":"-d connstr --dbname= connstr","source_url":"/docs/18/app-pgreceivewal.html","summary":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options."},{"description":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted.","names":["-h host","--host= host"],"signature":"-h host --host= host","source_url":"/docs/18/app-pgreceivewal.html","summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"description":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default.","names":["-p port","--port= port"],"signature":"-p port --port= port","source_url":"/docs/18/app-pgreceivewal.html","summary":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default."},{"description":"User name to connect as.","names":["-U username","--username= username"],"signature":"-U username --username= username","source_url":"/docs/18/app-pgreceivewal.html","summary":"User name to connect as."},{"description":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.","names":["-w","--no-password"],"signature":"-w --no-password","source_url":"/docs/18/app-pgreceivewal.html","summary":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"description":"Force pg_receivewal to prompt for a password before connecting to a database. This option is never essential, since pg_receivewal will automatically prompt for a password if the server demands password authentication. However, pg_receivewal will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.","names":["-W","--password"],"signature":"-W --password","source_url":"/docs/18/app-pgreceivewal.html","summary":"Force pg_receivewal to prompt for a password before connecting to a database."},{"description":"Create a new physical replication slot with the name specified in --slot , then exit.","names":["--create-slot"],"signature":"--create-slot","source_url":"/docs/18/app-pgreceivewal.html","summary":"Create a new physical replication slot with the name specified in --slot , then exit."},{"description":"Drop the replication slot with the name specified in --slot , then exit.","names":["--drop-slot"],"signature":"--drop-slot","source_url":"/docs/18/app-pgreceivewal.html","summary":"Drop the replication slot with the name specified in --slot , then exit."},{"description":"Print the pg_receivewal version and exit.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/app-pgreceivewal.html","summary":"Print the pg_receivewal version and exit."},{"description":"Show help about pg_receivewal command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help","source_url":"/docs/18/app-pgreceivewal.html","summary":"Show help about pg_receivewal command line arguments, and exit."}],"related":[{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"pg_receivewal [ option ...]","sources":[{"anchor":"","file":"app-pgreceivewal.html","label":"18.6 English manual · app-pgreceivewal.html","sha256":"a6f48474b24312a13fc108cfee2e960577f5bcf78e9993eaea04d39761c86ddc","url":"/docs/18/app-pgreceivewal.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}],"synopsis":["pg_receivewal [ option ...]"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-D directory --directory= directory","url":"/docs/18/app-pgreceivewal.html"},"summary":"Directory to write the output to."},{"signature":{"text":"-E lsn --endpos= lsn","url":"/docs/18/app-pgreceivewal.html"},"summary":"Automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN."},{"signature":{"text":"--if-not-exists","url":"/docs/18/app-pgreceivewal.html"},"summary":"Do not error out when --create-slot is specified and a slot with the specified name already exists."},{"signature":{"text":"-n --no-loop","url":"/docs/18/app-pgreceivewal.html"},"summary":"Don't loop on connection errors. Instead, exit right away with an error."},{"signature":{"text":"--no-sync","url":"/docs/18/app-pgreceivewal.html"},"summary":"This option causes pg_receivewal to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment."},{"signature":{"text":"-s interval --status-interval= interval","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds."},{"signature":{"text":"-S slotname --slot= slotname","url":"/docs/18/app-pgreceivewal.html"},"summary":"Require pg_receivewal to use an existing replication slot (see Section 26.2.6 ). When this option is used, pg_receivewal will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed."},{"signature":{"text":"--synchronous","url":"/docs/18/app-pgreceivewal.html"},"summary":"Flush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of --status-interval ."},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgreceivewal.html"},"summary":"Enables verbose mode."},{"signature":{"text":"-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]","url":"/docs/18/app-pgreceivewal.html"},"summary":"Enables compression of write-ahead logs."},{"signature":{"text":"-d connstr --dbname= connstr","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options."},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgreceivewal.html"},"summary":"User name to connect as."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgreceivewal.html"},"summary":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-pgreceivewal.html"},"summary":"Force pg_receivewal to prompt for a password before connecting to a database."},{"signature":{"text":"--create-slot","url":"/docs/18/app-pgreceivewal.html"},"summary":"Create a new physical replication slot with the name specified in --slot , then exit."},{"signature":{"text":"--drop-slot","url":"/docs/18/app-pgreceivewal.html"},"summary":"Drop the replication slot with the name specified in --slot , then exit."},{"signature":{"text":"-V --version","url":"/docs/18/app-pgreceivewal.html"},"summary":"Print the pg_receivewal version and exit."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgreceivewal.html"},"summary":"Show help about pg_receivewal command line arguments, and exit."}],"title":"Documented options"}]},"ManualEvidence":{"manual_path":"app-pgreceivewal.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"app-pgreceivewal.html","label":"18.6 English manual · app-pgreceivewal.html","sha256":"a6f48474b24312a13fc108cfee2e960577f5bcf78e9993eaea04d39761c86ddc","url":"/docs/18/app-pgreceivewal.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"pg-receivewal","SourceDatabase":"center","Version":"18","Locale":"en","Title":"pg_receivewal","Summary":"pg_receivewal — stream write-ahead logs from a PostgreSQL server","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"APP-PGRECEIVEWAL\"\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epg_receivewal\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_receivewal — stream write-ahead logs from a \u003cspan\u003ePostgreSQL\u003c/span\u003e server\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.4.17.4.1\"\u003e\u003ccode\u003epg_receivewal\u003c/code\u003e [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.17.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epg_receivewal\u003c/span\u003e is used to stream the write-ahead log from a running \u003cspan\u003ePostgreSQL\u003c/span\u003e cluster. The write-ahead log is streamed using the streaming replication protocol, and is written to a local directory of files. This directory can be used as the archive location for doing a restore using point-in-time recovery (see \u003ca href=\"/docs/18/continuous-archiving.html\" rel=\"nofollow\"\u003eSection 25.3\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epg_receivewal\u003c/span\u003e streams the write-ahead log in real time as it\u0026#39;s being generated on the server, and does not wait for segments to complete like \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\" rel=\"nofollow\"\u003earchive_command\u003c/a\u003e and \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\" rel=\"nofollow\"\u003earchive_library\u003c/a\u003e do. For this reason, it is not necessary to set \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT\" rel=\"nofollow\"\u003earchive_timeout\u003c/a\u003e when using \u003cspan\u003epg_receivewal\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eUnlike the WAL receiver of a PostgreSQL standby server, \u003cspan\u003epg_receivewal\u003c/span\u003e by default flushes WAL data only when a WAL file is closed. The option \u003ccode\u003e--synchronous\u003c/code\u003e must be specified to flush WAL data in real time. Since \u003cspan\u003epg_receivewal\u003c/span\u003e does not apply WAL, you should not allow it to become a synchronous standby when \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT\" rel=\"nofollow\"\u003esynchronous_commit\u003c/a\u003e equals \u003ccode\u003eremote_apply\u003c/code\u003e. If it does, it will appear to be a standby that never catches up, and will cause transaction commits to block. To avoid this, you should either configure an appropriate value for \u003ca href=\"/docs/18/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES\" rel=\"nofollow\"\u003esynchronous_standby_names\u003c/a\u003e, or specify \u003ccode\u003eapplication_name\u003c/code\u003e for \u003cspan\u003epg_receivewal\u003c/span\u003e that does not match it, or change the value of \u003ccode\u003esynchronous_commit\u003c/code\u003e to something other than \u003ccode\u003eremote_apply\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe write-ahead log is streamed over a regular \u003cspan\u003ePostgreSQL\u003c/span\u003e connection and uses the replication protocol. The connection must be made with a user having \u003ccode\u003eREPLICATION\u003c/code\u003e permissions (see \u003ca href=\"/docs/18/role-attributes.html\" rel=\"nofollow\"\u003eSection 21.2\u003c/a\u003e) or a superuser, and \u003ccode\u003epg_hba.conf\u003c/code\u003e must permit the replication connection. The server must also be configured with \u003ca href=\"/docs/18/runtime-config-replication.html#GUC-MAX-WAL-SENDERS\" rel=\"nofollow\"\u003emax_wal_senders\u003c/a\u003e set high enough to leave at least one session available for the stream.\u003c/p\u003e\n\u003cp\u003eThe starting point of the write-ahead log streaming is calculated when \u003cspan\u003epg_receivewal\u003c/span\u003e starts:\u003c/p\u003e\n\u003cdiv\u003e\n\u003col\u003e\n\u003cli\u003e\n\u003cp\u003eFirst, scan the directory where the WAL segment files are written and find the newest completed segment file, using as the starting point the beginning of the next WAL segment file.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eIf a starting point cannot be calculated with the previous method, and if a replication slot is used, an extra \u003ccode\u003eREAD_REPLICATION_SLOT\u003c/code\u003e command is issued to retrieve the slot\u0026#39;s \u003ccode\u003erestart_lsn\u003c/code\u003e to use as the starting point. This option is only available when streaming write-ahead logs from \u003cspan\u003ePostgreSQL\u003c/span\u003e 15 and up.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eIf a starting point cannot be calculated with the previous method, the latest WAL flush location is used as reported by the server from an \u003ccode\u003eIDENTIFY_SYSTEM\u003c/code\u003e command.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/div\u003e\n\u003cp\u003eIf the connection is lost, or if it cannot be initially established, with a non-fatal error, \u003cspan\u003epg_receivewal\u003c/span\u003e will retry the connection indefinitely, and reestablish streaming as soon as possible. To avoid this behavior, use the \u003ccode\u003e-n\u003c/code\u003e parameter.\u003c/p\u003e\n\u003cp\u003eIn the absence of fatal errors, \u003cspan\u003epg_receivewal\u003c/span\u003e will run until terminated by the \u003cspan\u003eSIGINT\u003c/span\u003e (\u003cspan\u003e\u003cstrong\u003eControl\u003c/strong\u003e\u003c/span\u003e+\u003cspan\u003e\u003cstrong\u003eC\u003c/strong\u003e\u003c/span\u003e) or \u003cspan\u003eSIGTERM\u003c/span\u003e signal.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.17.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-D \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--directory=\u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDirectory to write the output to.\u003c/p\u003e\n\u003cp\u003eThis parameter is required.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-E \u003cem\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--endpos=\u003cem\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAutomatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN.\u003c/p\u003e\n\u003cp\u003eIf there is a record with LSN exactly equal to \u003cem\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e, the record will be processed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--if-not-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not error out when \u003ccode\u003e--create-slot\u003c/code\u003e is specified and a slot with the specified name already exists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-loop\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDon\u0026#39;t loop on connection errors. Instead, exit right away with an error.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-sync\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option causes \u003ccode\u003epg_receivewal\u003c/code\u003e to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment.\u003c/p\u003e\n\u003cp\u003eThis option is incompatible with \u003ccode\u003e--synchronous\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-s \u003cem\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--status-interval=\u003cem\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-S \u003cem\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--slot=\u003cem\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequire \u003cspan\u003epg_receivewal\u003c/span\u003e to use an existing replication slot (see \u003ca href=\"/docs/18/warm-standby.html#STREAMING-REPLICATION-SLOTS\" rel=\"nofollow\"\u003eSection 26.2.6\u003c/a\u003e). When this option is used, \u003cspan\u003epg_receivewal\u003c/span\u003e will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed.\u003c/p\u003e\n\u003cp\u003eWhen the replication client of \u003cspan\u003epg_receivewal\u003c/span\u003e is configured on the server as a synchronous standby, then using a replication slot will report the flush position to the server, but only when a WAL file is closed. Therefore, that configuration will cause transactions on the primary to wait for a long time and effectively not work satisfactorily. The option \u003ccode\u003e--synchronous\u003c/code\u003e (see below) must be specified in addition to make this work correctly.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--synchronous\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eFlush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of \u003ccode\u003e--status-interval\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option should be specified if the replication client of \u003cspan\u003epg_receivewal\u003c/span\u003e is configured on the server as a synchronous standby, to ensure that timely feedback is sent to the server.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables verbose mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-Z \u003cem\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e-Z \u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--compress=\u003cem\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--compress=\u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables compression of write-ahead logs.\u003c/p\u003e\n\u003cp\u003eThe compression method can be set to \u003ccode\u003egzip\u003c/code\u003e, \u003ccode\u003elz4\u003c/code\u003e (if \u003cspan\u003ePostgreSQL\u003c/span\u003e was compiled with \u003ccode\u003e--with-lz4\u003c/code\u003e) or \u003ccode\u003enone\u003c/code\u003e for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form \u003cem\u003e\u003ccode\u003ekeyword\u003c/code\u003e\u003c/em\u003e or \u003cem\u003e\u003ccode\u003ekeyword=value\u003c/code\u003e\u003c/em\u003e. Currently, the only supported keyword is \u003ccode\u003elevel\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, \u003ccode\u003egzip\u003c/code\u003e compression will be used if the level is greater than 0, and no compression will be used if the level is 0.\u003c/p\u003e\n\u003cp\u003eThe suffix \u003ccode\u003e.gz\u003c/code\u003e will automatically be added to all filenames when using \u003ccode\u003egzip\u003c/code\u003e, and the suffix \u003ccode\u003e.lz4\u003c/code\u003e is added when using \u003ccode\u003elz4\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the database connection parameters.\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-d \u003cem\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--dbname=\u003cem\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies parameters used to connect to the server, as a \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" rel=\"nofollow\"\u003econnection string\u003c/a\u003e; these will override any conflicting command line options.\u003c/p\u003e\n\u003cp\u003eThis option is called \u003ccode\u003e--dbname\u003c/code\u003e for consistency with other client applications, but because \u003cspan\u003epg_receivewal\u003c/span\u003e doesn\u0026#39;t connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name (\u003ccode\u003ereplication\u003c/code\u003e) for purposes of looking up the replication connection\u0026#39;s password in \u003ccode\u003e~/.pgpass\u003c/code\u003e. Similarly, middleware or proxies used in connecting to \u003cspan\u003ePostgreSQL\u003c/span\u003e might utilize the name for purposes such as connection routing.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-h \u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--host=\u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the \u003ccode\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-p \u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--port=\u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-U \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--username=\u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUser name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan\u003epg_receivewal\u003c/span\u003e to prompt for a password before connecting to a database.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan\u003epg_receivewal\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan\u003epg_receivewal\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan\u003epg_receivewal\u003c/span\u003e can perform one of the two following actions in order to control physical replication slots:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--create-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a new physical replication slot with the name specified in \u003ccode\u003e--slot\u003c/code\u003e, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--drop-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDrop the replication slot with the name specified in \u003ccode\u003e--slot\u003c/code\u003e, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options are also available:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan\u003epg_receivewal\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan\u003epg_receivewal\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.17.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epg_receivewal\u003c/span\u003e will exit with status 0 when terminated by the \u003cspan\u003eSIGINT\u003c/span\u003e or \u003cspan\u003eSIGTERM\u003c/span\u003e signal. (That is the normal way to end it. Hence it is not an error.) For fatal errors or other signals, the exit status will be nonzero.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.17.8\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cp\u003eThis utility, like most other \u003cspan\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan\u003elibpq\u003c/span\u003e (see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and \u003ccode\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.17.9\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eWhen using \u003cspan\u003epg_receivewal\u003c/span\u003e instead of \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\" rel=\"nofollow\"\u003earchive_command\u003c/a\u003e or \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\" rel=\"nofollow\"\u003earchive_library\u003c/a\u003e as the main WAL backup method, it is strongly recommended to use replication slots. Otherwise, the server is free to recycle or remove write-ahead log files before they are backed up, because it does not have any information, either from \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\" rel=\"nofollow\"\u003earchive_command\u003c/a\u003e or \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\" rel=\"nofollow\"\u003earchive_library\u003c/a\u003e or the replication slots, about how far the WAL stream has been archived. Note, however, that a replication slot will fill up the server\u0026#39;s disk space if the receiver does not keep up with fetching the WAL data.\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epg_receivewal\u003c/span\u003e will preserve group permissions on the received WAL files if group permissions are enabled on the source cluster.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.17.10\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eTo stream the write-ahead log from the server at \u003ccode\u003emydbserver\u003c/code\u003e and store it in the local directory \u003ccode\u003e/usr/local/pgsql/archive\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_receivewal -h mydbserver -D /usr/local/pgsql/archive\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.17.11\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/docs/18/app-pgbasebackup.html\" title=\"pg_basebackup\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"5c31120c4d95b217f2e330627fafe46089b2f54a2d00d70ff3e13631937f11bd","Payload":{"description":["pg_receivewal — stream write-ahead logs from a PostgreSQL server"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGRECEIVEWAL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_receivewal — stream write-ahead logs from a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.17.4.1\"\u003e\u003ccode class=\"command\"\u003epg_receivewal\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e is used to stream the write-ahead log from a running \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e cluster. The write-ahead log is streamed using the streaming replication protocol, and is written to a local directory of files. This directory can be used as the archive location for doing a restore using point-in-time recovery (see \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html\" title=\"25.3. Continuous Archiving and Point-in-Time Recovery (PITR)\"\u003eSection 25.3\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e streams the write-ahead log in real time as it's being generated on the server, and does not wait for segments to complete like \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e and \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e do. For this reason, it is not necessary to set \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT\"\u003earchive_timeout\u003c/a\u003e when using \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eUnlike the WAL receiver of a PostgreSQL standby server, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e by default flushes WAL data only when a WAL file is closed. The option \u003ccode class=\"option\"\u003e--synchronous\u003c/code\u003e must be specified to flush WAL data in real time. Since \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e does not apply WAL, you should not allow it to become a synchronous standby when \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT\"\u003esynchronous_commit\u003c/a\u003e equals \u003ccode class=\"literal\"\u003eremote_apply\u003c/code\u003e. If it does, it will appear to be a standby that never catches up, and will cause transaction commits to block. To avoid this, you should either configure an appropriate value for \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES\"\u003esynchronous_standby_names\u003c/a\u003e, or specify \u003ccode class=\"varname\"\u003eapplication_name\u003c/code\u003e for \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e that does not match it, or change the value of \u003ccode class=\"varname\"\u003esynchronous_commit\u003c/code\u003e to something other than \u003ccode class=\"literal\"\u003eremote_apply\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe write-ahead log is streamed over a regular \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e connection and uses the replication protocol. The connection must be made with a user having \u003ccode class=\"literal\"\u003eREPLICATION\u003c/code\u003e permissions (see \u003ca class=\"xref\" href=\"/docs/18/role-attributes.html\" title=\"21.2. Role Attributes\"\u003eSection 21.2\u003c/a\u003e) or a superuser, and \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e must permit the replication connection. The server must also be configured with \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-MAX-WAL-SENDERS\"\u003emax_wal_senders\u003c/a\u003e set high enough to leave at least one session available for the stream.\u003c/p\u003e\n\u003cp\u003eThe starting point of the write-ahead log streaming is calculated when \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e starts:\u003c/p\u003e\n\u003cdiv class=\"orderedlist\"\u003e\n\u003col class=\"orderedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eFirst, scan the directory where the WAL segment files are written and find the newest completed segment file, using as the starting point the beginning of the next WAL segment file.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf a starting point cannot be calculated with the previous method, and if a replication slot is used, an extra \u003ccode class=\"command\"\u003eREAD_REPLICATION_SLOT\u003c/code\u003e command is issued to retrieve the slot's \u003ccode class=\"literal\"\u003erestart_lsn\u003c/code\u003e to use as the starting point. This option is only available when streaming write-ahead logs from \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 15 and up.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf a starting point cannot be calculated with the previous method, the latest WAL flush location is used as reported by the server from an \u003ccode class=\"literal\"\u003eIDENTIFY_SYSTEM\u003c/code\u003e command.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/div\u003e\n\u003cp\u003eIf the connection is lost, or if it cannot be initially established, with a non-fatal error, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will retry the connection indefinitely, and reestablish streaming as soon as possible. To avoid this behavior, use the \u003ccode class=\"literal\"\u003e-n\u003c/code\u003e parameter.\u003c/p\u003e\n\u003cp\u003eIn the absence of fatal errors, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will run until terminated by the \u003cspan class=\"systemitem\"\u003eSIGINT\u003c/span\u003e (\u003cspan class=\"keycap\"\u003e\u003cstrong\u003eControl\u003c/strong\u003e\u003c/span\u003e+\u003cspan class=\"keycap\"\u003e\u003cstrong\u003eC\u003c/strong\u003e\u003c/span\u003e) or \u003cspan class=\"systemitem\"\u003eSIGTERM\u003c/span\u003e signal.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--directory=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDirectory to write the output to.\u003c/p\u003e\n\u003cp\u003eThis parameter is required.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-E \u003cem class=\"replaceable\"\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--endpos=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAutomatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN.\u003c/p\u003e\n\u003cp\u003eIf there is a record with LSN exactly equal to \u003cem class=\"replaceable\"\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e, the record will be processed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-not-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not error out when \u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e is specified and a slot with the specified name already exists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-loop\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDon't loop on connection errors. Instead, exit right away with an error.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option causes \u003ccode class=\"command\"\u003epg_receivewal\u003c/code\u003e to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment.\u003c/p\u003e\n\u003cp\u003eThis option is incompatible with \u003ccode class=\"literal\"\u003e--synchronous\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s \u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--status-interval=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--slot=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequire \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e to use an existing replication slot (see \u003ca class=\"xref\" href=\"/docs/18/warm-standby.html#STREAMING-REPLICATION-SLOTS\" title=\"26.2.6. Replication Slots\"\u003eSection 26.2.6\u003c/a\u003e). When this option is used, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed.\u003c/p\u003e\n\u003cp\u003eWhen the replication client of \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e is configured on the server as a synchronous standby, then using a replication slot will report the flush position to the server, but only when a WAL file is closed. Therefore, that configuration will cause transactions on the primary to wait for a long time and effectively not work satisfactorily. The option \u003ccode class=\"literal\"\u003e--synchronous\u003c/code\u003e (see below) must be specified in addition to make this work correctly.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--synchronous\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eFlush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of \u003ccode class=\"literal\"\u003e--status-interval\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option should be specified if the replication client of \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e is configured on the server as a synchronous standby, to ensure that timely feedback is sent to the server.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables verbose mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z \u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z \u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables compression of write-ahead logs.\u003c/p\u003e\n\u003cp\u003eThe compression method can be set to \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e (if \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e was compiled with \u003ccode class=\"option\"\u003e--with-lz4\u003c/code\u003e) or \u003ccode class=\"literal\"\u003enone\u003c/code\u003e for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword\u003c/code\u003e\u003c/em\u003e or \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword=value\u003c/code\u003e\u003c/em\u003e. Currently, the only supported keyword is \u003ccode class=\"literal\"\u003elevel\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e compression will be used if the level is greater than 0, and no compression will be used if the level is 0.\u003c/p\u003e\n\u003cp\u003eThe suffix \u003ccode class=\"filename\"\u003e.gz\u003c/code\u003e will automatically be added to all filenames when using \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, and the suffix \u003ccode class=\"filename\"\u003e.lz4\u003c/code\u003e is added when using \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the database connection parameters.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies parameters used to connect to the server, as a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e; these will override any conflicting command line options.\u003c/p\u003e\n\u003cp\u003eThis option is called \u003ccode class=\"literal\"\u003e--dbname\u003c/code\u003e for consistency with other client applications, but because \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name (\u003ccode class=\"literal\"\u003ereplication\u003c/code\u003e) for purposes of looking up the replication connection's password in \u003ccode class=\"filename\"\u003e~/.pgpass\u003c/code\u003e. Similarly, middleware or proxies used in connecting to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e might utilize the name for purposes such as connection routing.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUser name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e to prompt for a password before connecting to a database.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e can perform one of the two following actions in order to control physical replication slots:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a new physical replication slot with the name specified in \u003ccode class=\"option\"\u003e--slot\u003c/code\u003e, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--drop-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDrop the replication slot with the name specified in \u003ccode class=\"option\"\u003e--slot\u003c/code\u003e, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options are also available:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will exit with status 0 when terminated by the \u003cspan class=\"systemitem\"\u003eSIGINT\u003c/span\u003e or \u003cspan class=\"systemitem\"\u003eSIGTERM\u003c/span\u003e signal. (That is the normal way to end it. Hence it is not an error.) For fatal errors or other signals, the exit status will be nonzero.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.8\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.9\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eWhen using \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e instead of \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e or \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e as the main WAL backup method, it is strongly recommended to use replication slots. Otherwise, the server is free to recycle or remove write-ahead log files before they are backed up, because it does not have any information, either from \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e or \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e or the replication slots, about how far the WAL stream has been archived. Note, however, that a replication slot will fill up the server's disk space if the receiver does not keep up with fetching the WAL data.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e will preserve group permissions on the received WAL files if group permissions are enabled on the source cluster.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.10\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eTo stream the write-ahead log from the server at \u003ccode class=\"literal\"\u003emydbserver\u003c/code\u003e and store it in the local directory \u003ccode class=\"filename\"\u003e/usr/local/pgsql/archive\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_receivewal -h mydbserver -D /usr/local/pgsql/archive\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.17.11\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgbasebackup.html\" title=\"pg_basebackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","related":[{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-D directory --directory= directory","url":"/docs/18/app-pgreceivewal.html"},"summary":"Directory to write the output to."},{"signature":{"text":"-E lsn --endpos= lsn","url":"/docs/18/app-pgreceivewal.html"},"summary":"Automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN."},{"signature":{"text":"--if-not-exists","url":"/docs/18/app-pgreceivewal.html"},"summary":"Do not error out when --create-slot is specified and a slot with the specified name already exists."},{"signature":{"text":"-n --no-loop","url":"/docs/18/app-pgreceivewal.html"},"summary":"Don't loop on connection errors. Instead, exit right away with an error."},{"signature":{"text":"--no-sync","url":"/docs/18/app-pgreceivewal.html"},"summary":"This option causes pg_receivewal to not force WAL data to be flushed to disk. This is faster, but means that a subsequent operating system crash can leave the WAL segments corrupt. Generally, this option is useful for testing but should not be used when doing WAL archiving on a production deployment."},{"signature":{"text":"-s interval --status-interval= interval","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies the number of seconds between status packets sent back to the server. This allows for easier monitoring of the progress from server. A value of zero disables the periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout disconnect. The default value is 10 seconds."},{"signature":{"text":"-S slotname --slot= slotname","url":"/docs/18/app-pgreceivewal.html"},"summary":"Require pg_receivewal to use an existing replication slot (see Section 26.2.6 ). When this option is used, pg_receivewal will report a flush position to the server, indicating when each segment has been synchronized to disk so that the server can remove that segment if it is not otherwise needed."},{"signature":{"text":"--synchronous","url":"/docs/18/app-pgreceivewal.html"},"summary":"Flush the WAL data to disk immediately after it has been received. Also send a status packet back to the server immediately after flushing, regardless of --status-interval ."},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgreceivewal.html"},"summary":"Enables verbose mode."},{"signature":{"text":"-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]","url":"/docs/18/app-pgreceivewal.html"},"summary":"Enables compression of write-ahead logs."},{"signature":{"text":"-d connstr --dbname= connstr","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options."},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgreceivewal.html"},"summary":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgreceivewal.html"},"summary":"User name to connect as."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgreceivewal.html"},"summary":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-pgreceivewal.html"},"summary":"Force pg_receivewal to prompt for a password before connecting to a database."},{"signature":{"text":"--create-slot","url":"/docs/18/app-pgreceivewal.html"},"summary":"Create a new physical replication slot with the name specified in --slot , then exit."},{"signature":{"text":"--drop-slot","url":"/docs/18/app-pgreceivewal.html"},"summary":"Drop the replication slot with the name specified in --slot , then exit."},{"signature":{"text":"-V --version","url":"/docs/18/app-pgreceivewal.html"},"summary":"Print the pg_receivewal version and exit."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgreceivewal.html"},"summary":"Show help about pg_receivewal command line arguments, and exit."}],"title":"Documented options"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
