v5-0002-Add-option-to-write-recovery-configuration-inform.patch
application/octet-stream
Filename: v5-0002-Add-option-to-write-recovery-configuration-inform.patch
Type: application/octet-stream
Part: 1
Patch
Format: format-patch
Series: patch v5-0002
Subject: Add option to write recovery configuration information in pg_rewind.
| File | + | − |
|---|---|---|
| doc/src/sgml/ref/pg_rewind.sgml | 11 | 0 |
| src/bin/pg_rewind/pg_rewind.c | 18 | 1 |
From f2357bfc5f1cb94ddb64323104bdaf8473480fdd Mon Sep 17 00:00:00 2001
From: Paul Guo <paulguo@gmail.com>
Date: Thu, 18 Apr 2019 19:37:36 +0800
Subject: [PATCH v5 2/3] Add option to write recovery configuration information
in pg_rewind.
---
doc/src/sgml/ref/pg_rewind.sgml | 11 +++++++++++
src/bin/pg_rewind/pg_rewind.c | 19 ++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/doc/src/sgml/ref/pg_rewind.sgml b/doc/src/sgml/ref/pg_rewind.sgml
index 52a1caa246..6a46b8c3b4 100644
--- a/doc/src/sgml/ref/pg_rewind.sgml
+++ b/doc/src/sgml/ref/pg_rewind.sgml
@@ -165,6 +165,17 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-R</option></term>
+ <term><option>--write-recovery-conf</option></term>
+ <listitem>
+ <para>
+ Create <filename>standby.signal</filename> and append connection settings
+ to <filename>postgresql.auto.conf</filename> in the output directory.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>-n</option></term>
<term><option>--dry-run</option></term>
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index e8674c24bb..48487d3448 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -76,6 +76,7 @@ usage(const char *progname)
printf(_(" -D, --target-pgdata=DIRECTORY existing data directory to modify\n"));
printf(_(" --source-pgdata=DIRECTORY source data directory to synchronize with\n"));
printf(_(" --source-server=CONNSTR source server to synchronize with\n"));
+ printf(_(" -R, --write-recovery-conf write configuration for replication\n"));
printf(_(" -n, --dry-run stop before modifying anything\n"));
printf(_(" -N, --no-sync do not wait for changes to be written\n"
" safely to disk\n"));
@@ -93,6 +94,7 @@ main(int argc, char **argv)
static struct option long_options[] = {
{"help", no_argument, NULL, '?'},
{"target-pgdata", required_argument, NULL, 'D'},
+ {"write-recovery-conf", no_argument, NULL, 'R'},
{"source-pgdata", required_argument, NULL, 1},
{"source-server", required_argument, NULL, 2},
{"version", no_argument, NULL, 'V'},
@@ -135,7 +137,7 @@ main(int argc, char **argv)
}
}
- while ((c = getopt_long(argc, argv, "D:nNP", long_options, &option_index)) != -1)
+ while ((c = getopt_long(argc, argv, "D:nNPR", long_options, &option_index)) != -1)
{
switch (c)
{
@@ -155,6 +157,10 @@ main(int argc, char **argv)
do_sync = false;
break;
+ case 'R':
+ writerecoveryconf = true;
+ break;
+
case 3:
debug = true;
pg_logging_set_level(PG_LOG_DEBUG);
@@ -301,6 +307,11 @@ main(int argc, char **argv)
if (!rewind_needed)
{
pg_log_info("no rewind required");
+ if (writerecoveryconf && connstr_source)
+ {
+ GenerateRecoveryConf();
+ WriteRecoveryConf(datadir_target);
+ }
exit(0);
}
@@ -398,6 +409,12 @@ main(int argc, char **argv)
pg_log_info("syncing target data directory");
syncTargetDirectory();
+ if (writerecoveryconf && connstr_source)
+ {
+ GenerateRecoveryConf();
+ WriteRecoveryConf(datadir_target);
+ }
+
pg_log_info("Done!");
return 0;
--
2.17.2