Skip to content

Commit 6fa7975

Browse files
committed
Add pg_basebackup -z option for compression with default level
1 parent cb0defe commit 6fa7975

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

doc/src/sgml/ref/pg_basebackup.sgml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,27 @@ PostgreSQL documentation
168168
</listitem>
169169
</varlistentry>
170170

171+
<varlistentry>
172+
<term><option>-z</option></term>
173+
<term><option>--gzip</option></term>
174+
<listitem>
175+
<para>
176+
Enables gzip compression of tar file output, with the default
177+
compression level. Compression is only available when using
178+
the tar format.
179+
</para>
180+
</listitem>
181+
</varlistentry>
182+
171183
<varlistentry>
172184
<term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
173185
<term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
174186
<listitem>
175187
<para>
176-
Enables gzip compression of tar file output. Compression is only
177-
available when using the tar format.
188+
Enables gzip compression of tar file output, and specifies the
189+
compression level (1 through 9, 9 being best
190+
compression). Compression is only available when using the tar
191+
format.
178192
</para>
179193
</listitem>
180194
</varlistentry>
@@ -393,11 +407,11 @@ PostgreSQL documentation
393407
</para>
394408

395409
<para>
396-
To create a backup of the local server with one maximum compressed
410+
To create a backup of the local server with one compressed
397411
tar file for each tablespace, and store it in the directory
398412
<filename>backup</filename>, showing a progress report while running:
399413
<screen>
400-
<prompt>$</prompt> <userinput>pg_basebackup -D backup -Ft -Z9 -P</userinput>
414+
<prompt>$</prompt> <userinput>pg_basebackup -D backup -Ft -z -P</userinput>
401415
</screen>
402416
</para>
403417

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ usage(void)
126126
printf(_(" -D, --pgdata=DIRECTORY receive base backup into directory\n"));
127127
printf(_(" -F, --format=p|t output format (plain, tar)\n"));
128128
printf(_(" -x, --xlog include required WAL files in backup\n"));
129-
printf(_(" -Z, --compress=0-9 compress tar output\n"));
129+
printf(_(" -z, --gzip compress tar output\n"));
130+
printf(_(" -Z, --compress=0-9 compress tar output with given compression level\n"));
130131
printf(_("\nGeneral options:\n"));
131132
printf(_(" -c, --checkpoint=fast|spread\n"
132133
" set fast or spread checkpointing\n"));
@@ -941,6 +942,7 @@ main(int argc, char **argv)
941942
{"format", required_argument, NULL, 'F'},
942943
{"checkpoint", required_argument, NULL, 'c'},
943944
{"xlog", no_argument, NULL, 'x'},
945+
{"gzip", no_argument, NULL, 'z'},
944946
{"compress", required_argument, NULL, 'Z'},
945947
{"label", required_argument, NULL, 'l'},
946948
{"host", required_argument, NULL, 'h'},
@@ -1000,6 +1002,13 @@ main(int argc, char **argv)
10001002
case 'l':
10011003
label = xstrdup(optarg);
10021004
break;
1005+
case 'z':
1006+
#ifdef HAVE_LIBZ
1007+
compresslevel = Z_DEFAULT_COMPRESSION;
1008+
#else
1009+
compresslevel = 1; /* will be rejected below */
1010+
#endif
1011+
break;
10031012
case 'Z':
10041013
compresslevel = atoi(optarg);
10051014
if (compresslevel <= 0 || compresslevel > 9)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy