@@ -376,6 +376,14 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
376376 </entry>
377377 </row>
378378
379+ <row>
380+ <entry><structname>pg_stat_progress_basebackup</structname><indexterm><primary>pg_stat_progress_basebackup</primary></indexterm></entry>
381+ <entry>One row for each WAL sender process streaming a base backup,
382+ showing current progress.
383+ See <xref linkend='basebackup-progress-reporting'/>.
384+ </entry>
385+ </row>
386+
379387 </tbody>
380388 </tgroup>
381389 </table>
@@ -3535,7 +3543,10 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
35353543 certain commands during command execution. Currently, the only commands
35363544 which support progress reporting are <command>ANALYZE</command>,
35373545 <command>CLUSTER</command>,
3538- <command>CREATE INDEX</command>, and <command>VACUUM</command>.
3546+ <command>CREATE INDEX</command>, <command>VACUUM</command>,
3547+ and <xref linkend="protocol-replication-base-backup"/> (i.e., replication
3548+ command that <xref linkend="app-pgbasebackup"/> issues to take
3549+ a base backup).
35393550 This may be expanded in the future.
35403551 </para>
35413552
@@ -4336,6 +4347,156 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
43364347 </tbody>
43374348 </tgroup>
43384349 </table>
4350+ </sect2>
4351+
4352+ <sect2 id="basebackup-progress-reporting">
4353+ <title>Base Backup Progress Reporting</title>
4354+
4355+ <para>
4356+ Whenever an application like <application>pg_basebackup</application>
4357+ is taking a base backup, the
4358+ <structname>pg_stat_progress_basebackup</structname>
4359+ view will contain a row for each WAL sender process that is currently
4360+ running <command>BASE_BACKUP</command> replication command
4361+ and streaming the backup. The tables below describe the information
4362+ that will be reported and provide information about how to interpret it.
4363+ </para>
4364+
4365+ <table id="pg-stat-progress-basebackup-view" xreflabel="pg_stat_progress_basebackup">
4366+ <title><structname>pg_stat_progress_basebackup</structname> View</title>
4367+ <tgroup cols="3">
4368+ <thead>
4369+ <row>
4370+ <entry>Column</entry>
4371+ <entry>Type</entry>
4372+ <entry>Description</entry>
4373+ </row>
4374+ </thead>
4375+
4376+ <tbody>
4377+ <row>
4378+ <entry><structfield>pid</structfield></entry>
4379+ <entry><type>integer</type></entry>
4380+ <entry>Process ID of a WAL sender process.</entry>
4381+ </row>
4382+ <row>
4383+ <entry><structfield>phase</structfield></entry>
4384+ <entry><type>text</type></entry>
4385+ <entry>Current processing phase. See <xref linkend="basebackup-phases" />.</entry>
4386+ </row>
4387+ <row>
4388+ <entry><structfield>backup_total</structfield></entry>
4389+ <entry><type>bigint</type></entry>
4390+ <entry>
4391+ Total amount of data that will be streamed. If progress reporting
4392+ is not enabled in <application>pg_basebackup</application>
4393+ (i.e., <literal>--progress</literal> option is not specified),
4394+ this is <literal>0</literal>. Otherwise, this is estimated and
4395+ reported as of the beginning of
4396+ <literal>streaming database files</literal> phase. Note that
4397+ this is only an approximation since the database
4398+ may change during <literal>streaming database files</literal> phase
4399+ and WAL log may be included in the backup later. This is always
4400+ the same value as <structfield>backup_streamed</structfield>
4401+ once the amount of data streamed exceeds the estimated
4402+ total size.
4403+ </entry>
4404+ </row>
4405+ <row>
4406+ <entry><structfield>backup_streamed</structfield></entry>
4407+ <entry><type>bigint</type></entry>
4408+ <entry>
4409+ Amount of data streamed. This counter only advances
4410+ when the phase is <literal>streaming database files</literal> or
4411+ <literal>transfering wal files</literal>.
4412+ </entry>
4413+ </row>
4414+ <row>
4415+ <entry><structfield>tablespaces_total</structfield></entry>
4416+ <entry><type>bigint</type></entry>
4417+ <entry>
4418+ Total number of tablespaces that will be streamed.
4419+ </entry>
4420+ </row>
4421+ <row>
4422+ <entry><structfield>tablespaces_streamed</structfield></entry>
4423+ <entry><type>bigint</type></entry>
4424+ <entry>
4425+ Number of tablespaces streamed. This counter only
4426+ advances when the phase is <literal>streaming database files</literal>.
4427+ </entry>
4428+ </row>
4429+ </tbody>
4430+ </tgroup>
4431+ </table>
4432+
4433+ <table id="basebackup-phases">
4434+ <title>Base backup phases</title>
4435+ <tgroup cols="2">
4436+ <thead>
4437+ <row>
4438+ <entry>Phase</entry>
4439+ <entry>Description</entry>
4440+ </row>
4441+ </thead>
4442+ <tbody>
4443+ <row>
4444+ <entry><literal>initializing</literal></entry>
4445+ <entry>
4446+ The WAL sender process is preparing to begin the backup.
4447+ This phase is expected to be very brief.
4448+ </entry>
4449+ </row>
4450+ <row>
4451+ <entry><literal>waiting for checkpoint to finish</literal></entry>
4452+ <entry>
4453+ The WAL sender process is currently performing
4454+ <function>pg_start_backup</function> to set up for
4455+ taking a base backup, and waiting for backup start
4456+ checkpoint to finish.
4457+ </entry>
4458+ </row>
4459+ <row>
4460+ <entry><literal>estimating backup size</literal></entry>
4461+ <entry>
4462+ The WAL sender process is currently estimating the total amount
4463+ of database files that will be streamed as a base backup.
4464+ </entry>
4465+ </row>
4466+ <row>
4467+ <entry><literal>streaming database files</literal></entry>
4468+ <entry>
4469+ The WAL sender process is currently streaming database files
4470+ as a base backup.
4471+ </entry>
4472+ </row>
4473+ <row>
4474+ <entry><literal>waiting for wal archiving to finish</literal></entry>
4475+ <entry>
4476+ The WAL sender process is currently performing
4477+ <function>pg_stop_backup</function> to finish the backup,
4478+ and waiting for all the WAL files required for the base backup
4479+ to be successfully archived.
4480+ If either <literal>--wal-method=none</literal> or
4481+ <literal>--wal-method=stream</literal> is specified in
4482+ <application>pg_basebackup</application>, the backup will end
4483+ when this phase is completed.
4484+ </entry>
4485+ </row>
4486+ <row>
4487+ <entry><literal>transferring wal files</literal></entry>
4488+ <entry>
4489+ The WAL sender process is currently transferring all WAL logs
4490+ generated during the backup. This phase occurs after
4491+ <literal>waiting for wal archiving to finish</literal> phase if
4492+ <literal>--wal-method=fetch</literal> is specified in
4493+ <application>pg_basebackup</application>. The backup will end
4494+ when this phase is completed.
4495+ </entry>
4496+ </row>
4497+ </tbody>
4498+ </tgroup>
4499+ </table>
43394500
43404501 </sect2>
43414502 </sect1>
0 commit comments