diff options
author | Fujii Masao <fujii@postgresql.org> | 2020-03-19 17:09:00 +0900 |
---|---|---|
committer | Fujii Masao <fujii@postgresql.org> | 2020-03-19 17:09:00 +0900 |
commit | fab13dc50ba5e7a12b474a7366024681bc169ac8 (patch) | |
tree | 209273b0ab152b4564e839ef22fd101969a43c1e /src | |
parent | c314c147c0563c9758bdad988ffda8d64daa2db6 (diff) | |
download | postgresql-fab13dc50ba5e7a12b474a7366024681bc169ac8.tar.gz postgresql-fab13dc50ba5e7a12b474a7366024681bc169ac8.zip |
Make pg_basebackup ask the server to estimate the total backup size, by default.
This commit changes pg_basebackup so that it specifies PROGRESS option in
BASE_BACKUP replication command whether --progress is specified or not.
This causes the server to estimate the total backup size and report it in
pg_stat_progress_basebackup.backup_total, by default. This is reasonable
default because the time required for the estimation would not be so large
in most cases.
Also this commit adds new option --no-estimate-size to pg_basebackup.
This option prevents the server from the estimation, and so is useful to
avoid such estimation time if it's too long.
Author: Fujii Masao
Reviewed-by: Magnus Hagander, Amit Langote
Discussion: https://postgr.es/m/CABUevEyDPPSjP7KRvfTXPdqOdY5aWNkqsB5aAXs3bco5ZwtGHg@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 48bd838803b..c5d95958b29 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -121,6 +121,7 @@ static char *label = "pg_basebackup base backup"; static bool noclean = false; static bool checksum_failure = false; static bool showprogress = false; +static bool estimatesize = true; static int verbose = 0; static int compresslevel = 0; static IncludeWal includewal = STREAM_WAL; @@ -386,6 +387,7 @@ usage(void) printf(_(" --no-slot prevent creation of temporary replication slot\n")); printf(_(" --no-verify-checksums\n" " do not verify checksums\n")); + printf(_(" --no-estimate-size do not estimate backup size in server side\n")); printf(_(" -?, --help show this help, then exit\n")); printf(_("\nConnection options:\n")); printf(_(" -d, --dbname=CONNSTR connection string\n")); @@ -1741,7 +1743,7 @@ BaseBackup(void) basebkp = psprintf("BASE_BACKUP LABEL '%s' %s %s %s %s %s %s %s", escaped_label, - showprogress ? "PROGRESS" : "", + estimatesize ? "PROGRESS" : "", includewal == FETCH_WAL ? "WAL" : "", fastcheckpoint ? "FAST" : "", includewal == NO_WAL ? "" : "NOWAIT", @@ -2066,6 +2068,7 @@ main(int argc, char **argv) {"waldir", required_argument, NULL, 1}, {"no-slot", no_argument, NULL, 2}, {"no-verify-checksums", no_argument, NULL, 3}, + {"no-estimate-size", no_argument, NULL, 4}, {NULL, 0, NULL, 0} }; int c; @@ -2234,6 +2237,9 @@ main(int argc, char **argv) case 3: verify_checksums = false; break; + case 4: + estimatesize = false; + break; default: /* @@ -2356,6 +2362,14 @@ main(int argc, char **argv) } #endif + if (showprogress && !estimatesize) + { + pg_log_error("--progress and --no-estimate-size are incompatible options"); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), + progname); + exit(1); + } + /* connection in replication mode to server */ conn = GetConnection(); if (!conn) |