Skip to content

Commit 751b8d2

Browse files
committed
pg_basebackup: Allow client-side LZ4 (de)compression.
LZ4 compression can now be performed on the client using pg_basebackup -Ft --compress client-lz4, and LZ4 decompression of a backup compressed on the server can be performed on the client using pg_basebackup -Fp --compress server-lz4. Dipesh Pandit, reviewed and tested by Jeevan Ladhe and Tushar Ahuja, with a few corrections - and some documentation - by me. Discussion: http://postgr.es/m/CAN1g5_FeDmiA9D8wdG2W6Lkq5CpubxOAqTmd2et9hsinTJtsMQ@mail.gmail.com
1 parent dab2984 commit 751b8d2

File tree

8 files changed

+606
-19
lines changed

8 files changed

+606
-19
lines changed

doc/src/sgml/ref/pg_basebackup.sgml

+15-12
Original file line numberDiff line numberDiff line change
@@ -417,18 +417,14 @@ PostgreSQL documentation
417417
specify <literal>-Xfetch</literal>.
418418
</para>
419419
<para>
420-
The compression method can be set to <literal>gzip</literal> for
421-
compression with <application>gzip</application>, or
422-
<literal>lz4</literal> for compression with
423-
<application>lz4</application>, or <literal>none</literal> for no
424-
compression. However, <literal>lz4</literal> can be currently only
425-
used with <literal>server</literal>. A compression level can be
426-
optionally specified, by appending the level number after a
427-
colon (<literal>:</literal>). If no level is specified, the default
428-
compression level will be used. If only a level is specified without
429-
mentioning an algorithm, <literal>gzip</literal> compression will
430-
be used if the level is greater than 0, and no compression will be
431-
used if the level is 0.
420+
The compression method can be set to <literal>gzip</literal> or
421+
<literal>lz4</literal>, or <literal>none</literal> for no
422+
compression. A compression level can be optionally specified, by
423+
appending the level number after a colon (<literal>:</literal>). If no
424+
level is specified, the default compression level will be used. If
425+
only a level is specified without mentioning an algorithm,
426+
<literal>gzip</literal> compression will be used if the level is
427+
greater than 0, and no compression will be used if the level is 0.
432428
</para>
433429
<para>
434430
When the tar format is used with <literal>gzip</literal> or
@@ -439,6 +435,13 @@ PostgreSQL documentation
439435
compression. If this is done, the server will compress the backup for
440436
transmission, and the client will decompress and extract it.
441437
</para>
438+
<para>
439+
When this option is used in combination with
440+
<literal>-Xstream</literal>, <literal>pg_wal.tar</literal> will
441+
be compressed using <literal>gzip</literal> if client-side gzip
442+
compression is selected, but will not be compressed if server-side
443+
compresion or LZ4 compresion is selected.
444+
</para>
442445
</listitem>
443446
</varlistentry>
444447
</variablelist>

src/bin/pg_basebackup/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ BBOBJS = \
4343
bbstreamer_file.o \
4444
bbstreamer_gzip.o \
4545
bbstreamer_inject.o \
46+
bbstreamer_lz4.o \
4647
bbstreamer_tar.o
4748

4849
all: pg_basebackup pg_receivewal pg_recvlogical

src/bin/pg_basebackup/bbstreamer.h

+3
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ extern bbstreamer *bbstreamer_extractor_new(const char *basepath,
206206
void (*report_output_file) (const char *));
207207

208208
extern bbstreamer *bbstreamer_gzip_decompressor_new(bbstreamer *next);
209+
extern bbstreamer *bbstreamer_lz4_compressor_new(bbstreamer *next,
210+
int compresslevel);
211+
extern bbstreamer *bbstreamer_lz4_decompressor_new(bbstreamer *next);
209212
extern bbstreamer *bbstreamer_tar_parser_new(bbstreamer *next);
210213
extern bbstreamer *bbstreamer_tar_terminator_new(bbstreamer *next);
211214
extern bbstreamer *bbstreamer_tar_archiver_new(bbstreamer *next);

0 commit comments

Comments
 (0)