From eb0af7ca23f32615d48be0bbc704265d09a03588 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 25 Aug 2015 14:36:51 +0900 Subject: [PATCH] Always pass -D/--pgdata option to pg_basebackup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit repmgr does not require explicit provision of the target data directory when cloning a standby (it defaults to the same directory as on the master). However this is a required option for pg_basebackup which was only being provided if repmgr's -D/--data-dir option was set, so ensure we always provide whatever repmgr is using. Per report from Martín. --- repmgr.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/repmgr.c b/repmgr.c index 2233d62b..1557146f 100644 --- a/repmgr.c +++ b/repmgr.c @@ -69,7 +69,7 @@ static bool create_recovery_file(const char *data_dir); static int test_ssh_connection(char *host, char *remote_user); static int copy_remote_files(char *host, char *remote_user, char *remote_path, char *local_path, bool is_directory, int server_version_num); -static int run_basebackup(void); +static int run_basebackup(const char *data_dir); static void check_parameters_for_action(const int action); static bool create_schema(PGconn *conn); static void write_primary_conninfo(char *line); @@ -1321,7 +1321,7 @@ do_standby_clone(void) } else { - r = run_basebackup(); + r = run_basebackup(local_data_directory); if (r != 0) { log_warning(_("standby clone: base backup failed\n")); @@ -2489,7 +2489,7 @@ copy_remote_files(char *host, char *remote_user, char *remote_path, static int -run_basebackup() +run_basebackup(const char *data_dir) { char script[MAXLEN]; int r = 0; @@ -2500,6 +2500,8 @@ run_basebackup() initPQExpBuffer(¶ms); + appendPQExpBuffer(¶ms, " -D %s", data_dir); + if(strlen(runtime_options.host)) { appendPQExpBuffer(¶ms, " -h %s", runtime_options.host); @@ -2515,11 +2517,6 @@ run_basebackup() appendPQExpBuffer(¶ms, " -U %s", runtime_options.username); } - if(strlen(runtime_options.dest_dir)) - { - appendPQExpBuffer(¶ms, " -D %s", runtime_options.dest_dir); - } - if(runtime_options.fast_checkpoint) { appendPQExpBuffer(¶ms, " -c fast"); }