{"Entry":{"collection":"tool","key":"pg-receivewal","name":"pg_receivewal","aliases":["pg_receivewal"],"metadata":{"aliases":["pg_receivewal"],"category":"Client applications","content_hash":"24fd837878b5828329dd5dabe482f7eedbf928f3954a5a5e0bef8793533886af","derived_content_hash":"d960518f6a04f6d29f6e047861d9e6cdf0e81f95b9c17f9c31755fcba7508520","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"],"description_zh":"描述 pg_receivewal 用于从正在运行的 PostgreSQL 数据库集簇流式接收预写式日志。预写式日志通过流复制协议传输，并写入本地目录中的文件。该目录可作为使用时间点恢复执行恢复时的归档位置（见 第 25.3 节 ）。 pg_receivewal 会在服务器生成预写式日志的同时实时流式接收，而不像 archive_command 和 archive_library 那样等待 WAL 段完成。因此，使用 pg_receivewal 时无需设置 archive_timeout 。 与 PostgreSQL 备库的 WAL 接收进程不同， pg_receivewal 默认只会在一个 WAL 文件关闭时才将 WAL 数据刷写到磁盘。要实时刷写 WAL 数据，必须指定 --synchronous 选项。由于 pg_receivewal 不会应用 WAL，因此当 synchronous_commit 等于 remote_apply 时，不应让它成为同步备库。如果这样做，它看起来会像一台永远追不上的备库，并导致事务提交阻塞。为避免这种情况，应当为 synchronous_standby_names 配置合适的值，或者为 pg_receivewal 指定一个与之不匹配的 application_name ，或者将 synchronous_commit 改成 remote_apply 以外的值。 预写式日志通过普通的 PostgreSQL 连接进行流式传输，并使用复制协议。建立该连接时，必须使用具有 REPLICATION 权限（见 第 21.2 节 ）的用户或超级用户，并且 pg_hba.conf 必须允许复制连接。服务器还必须将 max_wal_senders 设置得足够高，以便至少为该流保留一个可用会话。 预写式日志流式传输的起始位置会在 pg_receivewal 启动时计算出来： 首先，扫描写入 WAL 段文件的目录，找到最新的已完成段文件，并将下一个 WAL 段文件的开头作为起始位置。 如果无法用上述方法计算起始位置，并且使用了复制槽，则会额外发出 READ_R","description_zh_html":"\u003cp\u003e命令行工具 pg_receivewal [ option ...]。\u003c/p\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 用于从正在运行的 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 数据库集簇流式接收预写式日志。预写式日志通过流复制协议传输，并写入本地目录中的文件。该目录可作为使用时间点恢复执行恢复时的归档位置（见\u003ca class=\"xref\" href=\"/zh/docs/18/continuous-archiving.html\"\u003e第 25.3 节\u003c/a\u003e）。\n  \u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 会在服务器生成预写式日志的同时实时流式接收，而不像 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e 和 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e 那样等待 WAL 段完成。因此，使用 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 时无需设置 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT\"\u003earchive_timeout\u003c/a\u003e。\n  \u003c/p\u003e\u003cp\u003e\n   与 PostgreSQL 备库的 WAL 接收进程不同，\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 默认只会在一个 WAL 文件关闭时才将 WAL 数据刷写到磁盘。要实时刷写 WAL 数据，必须指定 \u003ccode class=\"option\"\u003e--synchronous\u003c/code\u003e 选项。由于 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 不会应用 WAL，因此当 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT\"\u003esynchronous_commit\u003c/a\u003e 等于 \u003ccode class=\"literal\"\u003eremote_apply\u003c/code\u003e 时，不应让它成为同步备库。如果这样做，它看起来会像一台永远追不上的备库，并导致事务提交阻塞。为避免这种情况，应当为 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES\"\u003esynchronous_standby_names\u003c/a\u003e 配置合适的值，或者为 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 指定一个与之不匹配的 \u003ccode class=\"varname\"\u003eapplication_name\u003c/code\u003e，或者将 \u003ccode class=\"varname\"\u003esynchronous_commit\u003c/code\u003e 改成 \u003ccode class=\"literal\"\u003eremote_apply\u003c/code\u003e 以外的值。\n  \u003c/p\u003e\u003cp\u003e\n   预写式日志通过普通的 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 连接进行流式传输，并使用复制协议。建立该连接时，必须使用具有 \u003ccode class=\"literal\"\u003eREPLICATION\u003c/code\u003e 权限（见\u003ca class=\"xref\" href=\"/zh/docs/18/role-attributes.html\"\u003e第 21.2 节\u003c/a\u003e）的用户或超级用户，并且 \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e 必须允许复制连接。服务器还必须将 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-replication.html#GUC-MAX-WAL-SENDERS\"\u003emax_wal_senders\u003c/a\u003e 设置得足够高，以便至少为该流保留一个可用会话。\n  \u003c/p\u003e\u003cp\u003e\n   预写式日志流式传输的起始位置会在 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 启动时计算出来：\n   \u003c/p\u003e\u003cdiv class=\"orderedlist\"\u003e\u003col class=\"orderedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n      首先，扫描写入 WAL 段文件的目录，找到最新的已完成段文件，并将下一个 WAL 段文件的开头作为起始位置。\n     \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n      如果无法用上述方法计算起始位置，并且使用了复制槽，则会额外发出 \u003ccode class=\"command\"\u003eREAD_REPLICATION_SLOT\u003c/code\u003e 命令，以获取该槽的 \u003ccode class=\"literal\"\u003erestart_lsn\u003c/code\u003e 作为起始位置。这种方式仅在从 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 15 及以上版本流式接收预写式日志时可用。\n     \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n      如果无法用上述方法计算起始位置，则使用服务器通过 \u003ccode class=\"literal\"\u003eIDENTIFY_SYSTEM\u003c/code\u003e 命令报告的最新 WAL 刷写位置。\n     \u003c/p\u003e\u003c/li\u003e\u003c/ol\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   如果因非致命错误导致连接中断或初次连接无法建立，\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 将无限期重试该连接，并尽快重新建立流式传输。要避免这种行为，请使用 \u003ccode class=\"literal\"\u003e-n\u003c/code\u003e 参数。\n  \u003c/p\u003e\u003cp\u003e\n   在没有致命错误的情况下，\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 会一直运行，直到收到 \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）或 \u003cspan class=\"systemitem\"\u003eSIGTERM\u003c/span\u003e 信号为止。\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e选项\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\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\u003cdd\u003e\u003cp\u003e\n        用于写入输出的目录。\n       \u003c/p\u003e\u003cp\u003e\n        这个参数是必需的。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        当接收位置到达指定 LSN 时，自动停止复制并以正常退出状态 0 退出。\n       \u003c/p\u003e\u003cp\u003e\n        如果存在 LSN 恰好等于 \u003cem class=\"replaceable\"\u003e\u003ccode\u003elsn\u003c/code\u003e\u003c/em\u003e 的记录，该记录也会被处理。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-not-exists\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        当指定 \u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e 且同名槽已存在时，不报错。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        遇到连接错误时不要循环重试，而是立即报错退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        此选项会使 \u003ccode class=\"command\"\u003epg_receivewal\u003c/code\u003e 不强制将 WAL 数据刷写到磁盘。这样会更快，但也意味着如果随后发生操作系统崩溃，可能会留下损坏的 WAL 段。一般来说，此选项适合测试，但不应在生产环境中执行 WAL 归档时使用。\n       \u003c/p\u003e\u003cp\u003e\n        这个选项与 \u003ccode class=\"literal\"\u003e--synchronous\u003c/code\u003e 不兼容。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        指定向服务器回送状态包的时间间隔（秒）。这样更便于从服务器端监视进度。值为零将完全禁用周期性状态更新，不过在服务器请求时仍会发送更新，以避免因超时而断开连接。默认值是 10 秒。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n         要求 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 使用一个现有复制槽（见\u003ca class=\"xref\" href=\"/zh/docs/18/warm-standby.html#STREAMING-REPLICATION-SLOTS\"\u003e第 26.2.6 节\u003c/a\u003e）。使用此选项时，\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 会向服务器报告刷写位置，指示每个段何时已同步到磁盘，以便服务器在该段不再被需要时将其移除。\n        \u003c/p\u003e\u003cp\u003e\n         当服务器将 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 的复制客户端配置为同步备库时，使用复制槽会向服务器报告刷写位置，但只会在一个 WAL 文件关闭时才报告。因此，这种配置会导致主库上的事务长时间等待，实际上无法令人满意地工作。要让这种配置正确工作，还必须另外指定 \u003ccode class=\"literal\"\u003e--synchronous\u003c/code\u003e 选项（见下文）。\n        \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--synchronous\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在收到 WAL 数据后立即将其刷写到磁盘。无论 \u003ccode class=\"literal\"\u003e--status-interval\u003c/code\u003e 如何，刷写后还会立即向服务器回送状态包。\n       \u003c/p\u003e\u003cp\u003e\n        如果服务器将 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 的复制客户端配置为同步备库，则应指定此选项，以确保及时向服务器发送反馈。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        启用详细输出模式。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        启用预写式日志的压缩。\n       \u003c/p\u003e\u003cp\u003e\n        压缩方法可以设置为 \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e、\u003ccode class=\"literal\"\u003elz4\u003c/code\u003e（如果 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 编译时启用了 \u003ccode class=\"option\"\u003e--with-lz4\u003c/code\u003e）或 \u003ccode class=\"literal\"\u003enone\u003c/code\u003e（不压缩）。还可以选择指定压缩细节字符串。如果该字符串是整数，则表示压缩级别；否则应为用逗号分隔的列表，其中每一项都采用 \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword\u003c/code\u003e\u003c/em\u003e 或 \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword=value\u003c/code\u003e\u003c/em\u003e 的形式。目前，唯一支持的关键字是 \u003ccode class=\"literal\"\u003elevel\u003c/code\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        如果未指定压缩级别，则使用默认压缩级别。如果只指定级别而未指明算法，则级别大于 0 时使用 \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e 压缩，级别为 0 时不使用压缩。\n       \u003c/p\u003e\u003cp\u003e\n        使用 \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e 时，所有文件名都会自动附加\u003ccode class=\"filename\"\u003e.gz\u003c/code\u003e 后缀；使用 \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e 时，则附加\u003ccode class=\"filename\"\u003e.lz4\u003c/code\u003e 后缀。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n    下列命令行选项控制数据库连接参数。\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\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\u003cdd\u003e\u003cp\u003e\n        以\u003ca class=\"link\" href=\"/zh/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\"\u003e连接字符串\u003c/a\u003e的形式指定用于连接到服务器的参数；这些参数会覆盖任何冲突的命令行选项。\n       \u003c/p\u003e\u003cp\u003e\n        为了与其他客户端应用保持一致，该选项被称为 \u003ccode class=\"literal\"\u003e--dbname\u003c/code\u003e。但由于 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 并不连接到集簇中的任何特定数据库，连接字符串中包含的数据库名会被服务器忽略。不过，以这种方式提供的数据库名会覆盖默认数据库名（\u003ccode class=\"literal\"\u003ereplication\u003c/code\u003e），用于在 \u003ccode class=\"filename\"\u003e~/.pgpass\u003c/code\u003e 中查找复制连接的密码。类似地，连接到 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 时使用的中间件或代理也可能将该名称用于连接路由等目的。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        指定运行服务器的主机名。如果该值以斜杠开头，则被用作 Unix 域套接字的目录。默认值取自 \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e 环境变量（如果已设置），否则尝试 Unix 域套接字连接。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        指定服务器正在监听连接的 TCP 端口，或本地 Unix 域套接字文件扩展名。默认值取自 \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e 环境变量（如果已设置），否则使用编译时的默认值。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        用于连接的用户名。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        绝不提示输入密码。如果服务器要求密码认证，而又无法通过\u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e 文件等其他方式获得密码，则连接尝试将会失败。此选项可用于批处理作业和脚本，因为这些场景中没有用户在场输入密码。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n        强制 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 在建立连接前提示输入密码。\n       \u003c/p\u003e\u003cp\u003e\n        这个选项从来都不是必需的，因为如果服务器要求密码认证，\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 会自动提示输入密码。不过，\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 需要先浪费一次连接尝试，才能发现服务器需要密码。在某些情况下，输入 \u003ccode class=\"option\"\u003e-W\u003c/code\u003e 以避免这次额外的连接尝试是值得的。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n    为了控制物理复制槽，\u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e\n    可以执行下列两种操作之一：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        使用 \u003ccode class=\"option\"\u003e--slot\u003c/code\u003e 中指定的名称创建一个新的物理复制槽，然后退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--drop-slot\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        删除 \u003ccode class=\"option\"\u003e--slot\u003c/code\u003e 中指定名称的复制槽，然后退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n    还可以使用下列其他选项：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\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\u003cdd\u003e\u003cp\u003e\n       打印 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 的版本并退出。\n       \u003c/p\u003e\u003c/dd\u003e\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\u003cdd\u003e\u003cp\u003e\n       显示 \u003cspan class=\"application\"\u003epg_receivewal\u003c/span\u003e 命令行参数的帮助并退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/app-pgreceivewal.html\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","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"}],"facts_zh":[{"label":"手册中的可执行程序","value":"pg_receivewal"},{"label":"程序版本","value":"18.6"},{"label":"参考清单","value":"客户端程序"},{"label":"选项定义组","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":[],"sections_zh":[],"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"}],"tables_zh":[{"columns":[{"key":"signature","label":"选项与参数"},{"key":"summary","label":"说明"}],"key":"options","rows":[{"signature":{"text":"-D directory --directory= directory","url":"/docs/18/app-pgreceivewal.html"},"summary":"用于写入输出的目录。"},{"signature":{"text":"-E lsn --endpos= lsn","url":"/docs/18/app-pgreceivewal.html"},"summary":"当接收位置到达指定 LSN 时，自动停止复制并以正常退出状态 0 退出。"},{"signature":{"text":"--if-not-exists","url":"/docs/18/app-pgreceivewal.html"},"summary":"当指定 --create-slot 且同名槽已存在时，不报错。"},{"signature":{"text":"-n --no-loop","url":"/docs/18/app-pgreceivewal.html"},"summary":"遇到连接错误时不要循环重试，而是立即报错退出。"},{"signature":{"text":"--no-sync","url":"/docs/18/app-pgreceivewal.html"},"summary":"此选项会使 pg_receivewal 不强制将 WAL 数据刷写到磁盘。这样会更快，但也意味着如果随后发生操作系统崩溃，可能会留下损坏的 WAL 段。一般来说，此选项适合测试，但不应在生产环境中执行 WAL 归档时使用。"},{"signature":{"text":"-s interval --status-interval= interval","url":"/docs/18/app-pgreceivewal.html"},"summary":"指定向服务器回送状态包的时间间隔（秒）。这样更便于从服务器端监视进度。值为零将完全禁用周期性状态更新，不过在服务器请求时仍会发送更新，以避免因超时而断开连接。默认值是 10 秒。"},{"signature":{"text":"-S slotname --slot= slotname","url":"/docs/18/app-pgreceivewal.html"},"summary":"要求 pg_receivewal 使用一个现有复制槽（见 第 26.2.6 节 ）。使用此选项时， pg_receivewal 会向服务器报告刷写位置，指示每个段何时已同步到磁盘，以便服务器在该段不再被需要时将其移除。"},{"signature":{"text":"--synchronous","url":"/docs/18/app-pgreceivewal.html"},"summary":"在收到 WAL 数据后立即将其刷写到磁盘。无论 --status-interval 如何，刷写后还会立即向服务器回送状态包。"},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgreceivewal.html"},"summary":"启用详细输出模式。"},{"signature":{"text":"-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]","url":"/docs/18/app-pgreceivewal.html"},"summary":"启用预写式日志的压缩。"},{"signature":{"text":"-d connstr --dbname= connstr","url":"/docs/18/app-pgreceivewal.html"},"summary":"以 连接字符串 的形式指定用于连接到服务器的参数；这些参数会覆盖任何冲突的命令行选项。"},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgreceivewal.html"},"summary":"指定运行服务器的主机名。如果该值以斜杠开头，则被用作 Unix 域套接字的目录。默认值取自 PGHOST 环境变量（如果已设置），否则尝试 Unix 域套接字连接。"},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgreceivewal.html"},"summary":"指定服务器正在监听连接的 TCP 端口，或本地 Unix 域套接字文件扩展名。默认值取自 PGPORT 环境变量（如果已设置），否则使用编译时的默认值。"},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgreceivewal.html"},"summary":"用于连接的用户名。"},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgreceivewal.html"},"summary":"绝不提示输入密码。如果服务器要求密码认证，而又无法通过 .pgpass 文件等其他方式获得密码，则连接尝试将会失败。此选项可用于批处理作业和脚本，因为这些场景中没有用户在场输入密码。"},{"signature":{"text":"-W --password","url":"/docs/18/app-pgreceivewal.html"},"summary":"强制 pg_receivewal 在建立连接前提示输入密码。"},{"signature":{"text":"--create-slot","url":"/docs/18/app-pgreceivewal.html"},"summary":"使用 --slot 中指定的名称创建一个新的物理复制槽，然后退出。"},{"signature":{"text":"--drop-slot","url":"/docs/18/app-pgreceivewal.html"},"summary":"删除 --slot 中指定名称的复制槽，然后退出。"},{"signature":{"text":"-V --version","url":"/docs/18/app-pgreceivewal.html"},"summary":"打印 pg_receivewal 的版本并退出。"},{"signature":{"text":"-? --help","url":"/docs/18/app-pgreceivewal.html"},"summary":"显示 pg_receivewal 命令行参数的帮助并退出。"}],"title":"手册中的选项"}],"zh_from":{"authored_translation":"source-derived-identity","body_sha256":"2d5b698e2ef770f906ee6d18193c7e06585e3de0bdf47caafd0f8d845a407a87","kind":"same-version-chinese-manual-with-source-derived-identity","manual":{"anchor":"","build_id":107,"extraction":"command-description-and-options","fragment_sha256":"6721d59725390d519176d03453181b13869b64d9604fc249ee3d59fb6b6aaaf9","locale":"zh-Hans","page_key":"app-pgreceivewal.html","source_hash":"ba50024ddf846e41ae637441a9f20109a03ec8bebfd13d4163881313667f877e","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/app-pgreceivewal.html","version":"18"},"runtime_rerun":false,"source_facts_revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}},"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":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
