aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2011-05-30 01:02:02 +0300
committerPeter Eisentraut <peter_e@gmx.net>2011-05-30 01:02:02 +0300
commit6fa79755bd393cdfadb6197164cbe01498474be3 (patch)
tree0d59b30c7b74e824ea661d27b652128aaecbf501
parentcb0defe5230f3773feb334a01b990c9eaaca301b (diff)
downloadpostgresql-6fa79755bd393cdfadb6197164cbe01498474be3.tar.gz
postgresql-6fa79755bd393cdfadb6197164cbe01498474be3.zip
Add pg_basebackup -z option for compression with default level
-rw-r--r--doc/src/sgml/ref/pg_basebackup.sgml22
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c11
2 files changed, 28 insertions, 5 deletions
diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml
index 32fa9f858ca..47dce43b194 100644
--- a/doc/src/sgml/ref/pg_basebackup.sgml
+++ b/doc/src/sgml/ref/pg_basebackup.sgml
@@ -169,12 +169,26 @@ PostgreSQL documentation
</varlistentry>
<varlistentry>
+ <term><option>-z</option></term>
+ <term><option>--gzip</option></term>
+ <listitem>
+ <para>
+ Enables gzip compression of tar file output, with the default
+ compression level. Compression is only available when using
+ the tar format.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
<term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
<listitem>
<para>
- Enables gzip compression of tar file output. Compression is only
- available when using the tar format.
+ Enables gzip compression of tar file output, and specifies the
+ compression level (1 through 9, 9 being best
+ compression). Compression is only available when using the tar
+ format.
</para>
</listitem>
</varlistentry>
@@ -393,11 +407,11 @@ PostgreSQL documentation
</para>
<para>
- To create a backup of the local server with one maximum compressed
+ To create a backup of the local server with one compressed
tar file for each tablespace, and store it in the directory
<filename>backup</filename>, showing a progress report while running:
<screen>
-<prompt>$</prompt> <userinput>pg_basebackup -D backup -Ft -Z9 -P</userinput>
+<prompt>$</prompt> <userinput>pg_basebackup -D backup -Ft -z -P</userinput>
</screen>
</para>
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 2af7b50586f..036d3ae7627 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -126,7 +126,8 @@ usage(void)
printf(_(" -D, --pgdata=DIRECTORY receive base backup into directory\n"));
printf(_(" -F, --format=p|t output format (plain, tar)\n"));
printf(_(" -x, --xlog include required WAL files in backup\n"));
- printf(_(" -Z, --compress=0-9 compress tar output\n"));
+ printf(_(" -z, --gzip compress tar output\n"));
+ printf(_(" -Z, --compress=0-9 compress tar output with given compression level\n"));
printf(_("\nGeneral options:\n"));
printf(_(" -c, --checkpoint=fast|spread\n"
" set fast or spread checkpointing\n"));
@@ -941,6 +942,7 @@ main(int argc, char **argv)
{"format", required_argument, NULL, 'F'},
{"checkpoint", required_argument, NULL, 'c'},
{"xlog", no_argument, NULL, 'x'},
+ {"gzip", no_argument, NULL, 'z'},
{"compress", required_argument, NULL, 'Z'},
{"label", required_argument, NULL, 'l'},
{"host", required_argument, NULL, 'h'},
@@ -1000,6 +1002,13 @@ main(int argc, char **argv)
case 'l':
label = xstrdup(optarg);
break;
+ case 'z':
+#ifdef HAVE_LIBZ
+ compresslevel = Z_DEFAULT_COMPRESSION;
+#else
+ compresslevel = 1; /* will be rejected below */
+#endif
+ break;
case 'Z':
compresslevel = atoi(optarg);
if (compresslevel <= 0 || compresslevel > 9)