char *datadir_source = NULL;
char *connstr_source = NULL;
char *restore_command = NULL;
+char *config_file = NULL;
static bool debug = false;
bool showprogress = false;
printf(_("Options:\n"));
printf(_(" -c, --restore-target-wal use restore_command in target configuration to\n"
" retrieve WAL files from archives\n"));
+ printf(_(" --config-file=FILENAME use specified main server configuration\n"));
+ printf(_(" file when running target cluster\n"));
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"));
{"source-pgdata", required_argument, NULL, 1},
{"source-server", required_argument, NULL, 2},
{"no-ensure-shutdown", no_argument, NULL, 4},
+ {"config-file", required_argument, NULL, 5},
{"version", no_argument, NULL, 'V'},
{"restore-target-wal", no_argument, NULL, 'c'},
{"dry-run", no_argument, NULL, 'n'},
case 4:
no_ensure_shutdown = true;
break;
+
+ case 5:
+ config_file = pg_strdup(optarg);
+ break;
}
}
appendPQExpBufferStr(postgres_cmd, " -D ");
appendShellString(postgres_cmd, datadir_target);
+ /* add custom configuration file only if requested */
+ if (config_file != NULL)
+ {
+ appendPQExpBufferStr(postgres_cmd, " -c config_file=");
+ appendShellString(postgres_cmd, config_file);
+ }
+
/* add -C switch, for restore_command */
appendPQExpBufferStr(postgres_cmd, " -C restore_command");
appendPQExpBufferStr(postgres_cmd, " --single -F -D ");
appendShellString(postgres_cmd, datadir_target);
+ /* add custom configuration file only if requested */
+ if (config_file != NULL)
+ {
+ appendPQExpBufferStr(postgres_cmd, " -c config_file=");
+ appendShellString(postgres_cmd, config_file);
+ }
+
/* finish with the database name, and a properly quoted redirection */
appendPQExpBufferStr(postgres_cmd, " template1 < ");
appendShellString(postgres_cmd, DEVNULL);
"--debug",
"--source-pgdata=$standby_pgdata",
"--target-pgdata=$primary_pgdata",
- "--no-sync"
+ "--no-sync",
+ "--config-file",
+ "$tmp_folder/primary-postgresql.conf.tmp"
],
'pg_rewind local');
}
'pg_rewind', "--debug",
"--source-server", $standby_connstr,
"--target-pgdata=$primary_pgdata", "--no-sync",
- "--write-recovery-conf"
+ "--write-recovery-conf", "--config-file",
+ "$tmp_folder/primary-postgresql.conf.tmp"
],
'pg_rewind remote');
# Note the use of --no-ensure-shutdown here. WAL files are
# gone in this mode and the primary has been stopped
- # gracefully already.
+ # gracefully already. --config-file reuses the original
+ # postgresql.conf as restore_command has been enabled above.
command_ok(
[
'pg_rewind',
"--target-pgdata=$primary_pgdata",
"--no-sync",
"--no-ensure-shutdown",
- "--restore-target-wal"
+ "--restore-target-wal",
+ "--config-file",
+ "$primary_pgdata/postgresql.conf"
],
'pg_rewind archive');
}