Created
March 24, 2016 09:45
-
-
Save kshvakov/63ccab91a7b35cf80292 to your computer and use it in GitHub Desktop.
Backport pg_basebackup --slot option from 9.6 to 9.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- src/bin/pg_basebackup/pg_basebackup_origin.c 2016-03-24 12:42:30.312362751 +0300 | |
+++ src/bin/pg_basebackup/pg_basebackup.c 2016-03-24 09:45:40.804376436 +0300 | |
@@ -239,6 +239,7 @@ | |
" (in kB/s, or use suffix \"k\" or \"M\")\n")); | |
printf(_(" -R, --write-recovery-conf\n" | |
" write recovery.conf after backup\n")); | |
+ printf(_(" -S, --slot=SLOTNAME replication slot to use\n")); | |
printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n" | |
" relocate tablespace in OLDDIR to NEWDIR\n")); | |
printf(_(" -x, --xlog include required WAL files in backup (fetch mode)\n")); | |
@@ -1526,6 +1527,13 @@ | |
appendPQExpBuffer(recoveryconfcontents, "primary_conninfo = '%s'\n", escaped); | |
free(escaped); | |
+ if (replication_slot) | |
+ { | |
+ escaped = escape_quotes(replication_slot); | |
+ appendPQExpBuffer(recoveryconfcontents, "primary_slot_name = '%s'\n", replication_slot); | |
+ free(escaped); | |
+ } | |
+ | |
if (PQExpBufferBroken(recoveryconfcontents) || | |
PQExpBufferDataBroken(conninfo_buf)) | |
{ | |
@@ -1924,6 +1932,7 @@ | |
{"checkpoint", required_argument, NULL, 'c'}, | |
{"max-rate", required_argument, NULL, 'r'}, | |
{"write-recovery-conf", no_argument, NULL, 'R'}, | |
+ {"slot", required_argument, NULL, 'S'}, | |
{"tablespace-mapping", required_argument, NULL, 'T'}, | |
{"xlog", no_argument, NULL, 'x'}, | |
{"xlog-method", required_argument, NULL, 'X'}, | |
@@ -1964,7 +1973,8 @@ | |
} | |
} | |
- while ((c = getopt_long(argc, argv, "D:F:r:RT:xX:l:zZ:d:c:h:p:U:s:wWvP", | |
+ | |
+ while ((c = getopt_long(argc, argv, "D:F:r:RT:xX:l:zZ:d:c:h:p:U:s:S:wWvP", | |
long_options, &option_index)) != -1) | |
{ | |
switch (c) | |
@@ -1991,6 +2001,9 @@ | |
case 'R': | |
writerecoveryconf = true; | |
break; | |
+ case 'S': | |
+ replication_slot = pg_strdup(optarg); | |
+ break; | |
case 'T': | |
tablespace_list_append(optarg); | |
break; | |
@@ -2154,7 +2167,15 @@ | |
progname); | |
exit(1); | |
} | |
- | |
+ if (replication_slot && !streamwal) | |
+ { | |
+ fprintf(stderr, | |
+ _("%s: replication slots can only be used with WAL streaming\n"), | |
+ progname); | |
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), | |
+ progname); | |
+ exit(1); | |
+ } | |
if (strcmp(xlog_dir, "") != 0) | |
{ | |
if (format != 'p') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment