Home Explore Blog CI



postgresql

7th chunk of `doc/src/sgml/ref/pg_basebackup.sgml`
fdf001a85eab3599749288bfe77a4df5350202df1348c0ed0000000100000faf
 available when using
        the tar format, and the suffix <filename>.gz</filename> will
        automatically be added to all tar filenames.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
      <term><option>-Z [{client|server}-]<replaceable class="parameter">method</replaceable>[:<replaceable>detail</replaceable>]</option></term>
      <term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
      <term><option>--compress=[{client|server}-]<replaceable class="parameter">method</replaceable>[:<replaceable>detail</replaceable>]</option></term>
      <listitem>
       <para>
        Requests compression of the backup. If <literal>client</literal> or
        <literal>server</literal> is included, it specifies where the
        compression is to be performed. Compressing on the server will reduce
        transfer bandwidth but will increase server CPU consumption.  The
        default is <literal>client</literal> except when
        <literal>--target</literal> is used. In that case, the backup is not
        being sent to the client, so only server compression is sensible.
        When <literal>-Xstream</literal>, which is the default, is used,
        server-side compression will not be applied to the WAL. To compress
        the WAL, use client-side compression, or
        specify <literal>-Xfetch</literal>.
       </para>
       <para>
        The compression method can be set to <literal>gzip</literal>,
        <literal>lz4</literal>, <literal>zstd</literal>,
        <literal>none</literal> for no compression or an integer (no
        compression if 0, <literal>gzip</literal> if greater than 0).
        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
        <replaceable>keyword</replaceable> or
        <replaceable>keyword=value</replaceable>.
        Currently, the supported keywords are <literal>level</literal>,
        <literal>long</literal>, and <literal>workers</literal>.
        The detail string cannot be used when the compression method
        is specified as a plain integer.
       </para>
       <para>
        If no compression level is specified, the default compression level
        will be used. If only a level is specified without mentioning an
        algorithm, <literal>gzip</literal> compression will be used if the
        level is greater than 0, and no compression will be used if the level
        is 0.
       </para>
       <para>
        When the tar format is used with <literal>gzip</literal>,
        <literal>lz4</literal>, or <literal>zstd</literal>, the suffix
        <filename>.gz</filename>, <filename>.lz4</filename>, or
        <filename>.zst</filename>, respectively, will be automatically added to
        all tar filenames. When the plain format is used, client-side
        compression may not be specified, but it is still possible to request
        server-side compression. If this is done, the server will compress the
        backup for transmission, and the client will decompress and extract it.
       </para>
       <para>
        When this option is used in combination with
        <literal>-Xstream</literal>, <literal>pg_wal.tar</literal> will
        be compressed using <literal>gzip</literal> if client-side gzip
        compression is selected, but will not be compressed if any other
        compression algorithm is selected, or if server-side compression
        is selected.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
   <para>
    The following command-line options control the generation of the
    backup and the invocation of the program:

    <variablelist>
     <varlistentry>
      <term><option>-c {fast|spread}</option></term>

Title: pg_basebackup: Detailed Compression Options
Summary
This section describes the advanced compression options available in `pg_basebackup`. It covers specifying client-side or server-side compression, choosing compression methods like gzip, lz4, or zstd, setting compression levels, and using detail strings for algorithm-specific settings. It also explains how file suffixes are automatically added for different compression types and how compression interacts with WAL streaming and plain format backups.