mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Add repmgr.conf setting 'barman_config'
Enables provision of a non-default Barman configuration file.
This commit is contained in:
@@ -571,7 +571,7 @@ development team, which must be copied in a location accessible to
|
||||
`repmgr`, and marked as executable; `restore_command` must then be
|
||||
set in `repmgr.conf` as follows:
|
||||
|
||||
<script> <Barman hostname> <cluster_name> %f %p
|
||||
<script> <Barman hostname> <cluster_name> %f %p
|
||||
|
||||
For instance, suppose that we have installed Barman on the `barmansrv`
|
||||
host, and that we have placed a copy of `barman-wal-restore.py` into
|
||||
@@ -585,6 +585,11 @@ Then we check that `repmgr.conf` includes the following lines:
|
||||
barman_server=barmansrv
|
||||
restore_command=/usr/local/bin/barman-wal-restore.py barmansrv test %f %p
|
||||
|
||||
To use a non-default Barman configuration file on the Barman server,
|
||||
specify this in `repmgr.conf` with `barman_config`:
|
||||
|
||||
barman_config=/path/to/barman.conf
|
||||
|
||||
Now we can clone a standby using the Barman server:
|
||||
|
||||
$ repmgr -h node1 -D 9.5/main -f /etc/repmgr.conf standby clone
|
||||
@@ -595,6 +600,8 @@ Now we can clone a standby using the Barman server:
|
||||
[2016-06-12 20:08:36] [HINT] for example : pg_ctl -D 9.5/data start
|
||||
[2016-06-12 20:08:36] [HINT] After starting the server, you need to register this standby with "repmgr standby register"
|
||||
|
||||
|
||||
|
||||
Advanced options for cloning a standby
|
||||
--------------------------------------
|
||||
|
||||
|
||||
3
config.c
3
config.c
@@ -216,6 +216,7 @@ parse_config(t_configuration_options *options)
|
||||
options->use_replication_slots = 0;
|
||||
memset(options->conninfo, 0, sizeof(options->conninfo));
|
||||
memset(options->barman_server, 0, sizeof(options->barman_server));
|
||||
memset(options->barman_config, 0, sizeof(options->barman_config));
|
||||
options->failover = MANUAL_FAILOVER;
|
||||
options->priority = DEFAULT_PRIORITY;
|
||||
memset(options->node_name, 0, sizeof(options->node_name));
|
||||
@@ -313,6 +314,8 @@ parse_config(t_configuration_options *options)
|
||||
strncpy(options->conninfo, value, MAXLEN);
|
||||
else if (strcmp(name, "barman_server") == 0)
|
||||
strncpy(options->barman_server, value, MAXLEN);
|
||||
else if (strcmp(name, "barman_config") == 0)
|
||||
strncpy(options->barman_config, value, MAXLEN);
|
||||
else if (strcmp(name, "rsync_options") == 0)
|
||||
strncpy(options->rsync_options, value, QUERY_STR_LEN);
|
||||
else if (strcmp(name, "ssh_options") == 0)
|
||||
|
||||
3
config.h
3
config.h
@@ -59,6 +59,7 @@ typedef struct
|
||||
int upstream_node;
|
||||
char conninfo[MAXLEN];
|
||||
char barman_server[MAXLEN];
|
||||
char barman_config[MAXLEN];
|
||||
int failover;
|
||||
int priority;
|
||||
char node_name[MAXLEN];
|
||||
@@ -92,7 +93,7 @@ typedef struct
|
||||
* The following will initialize the structure with a minimal set of options;
|
||||
* actual defaults are set in parse_config() before parsing the configuration file
|
||||
*/
|
||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, {NULL, NULL} }
|
||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", "", "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, {NULL, NULL} }
|
||||
|
||||
typedef struct ItemListCell
|
||||
{
|
||||
|
||||
35
repmgr.c
35
repmgr.c
@@ -111,6 +111,7 @@ static char *string_skip_prefix(const char *prefix, char *string);
|
||||
static char *string_remove_trailing_newlines(char *string);
|
||||
|
||||
static char *make_pg_path(char *file);
|
||||
static char *make_barman_ssh_command(void);
|
||||
|
||||
static void do_master_register(void);
|
||||
|
||||
@@ -137,6 +138,7 @@ static void print_error_list(ItemList *error_list, int log_level);
|
||||
|
||||
static bool remote_command(const char *host, const char *user, const char *command, PQExpBufferData *outputbuf);
|
||||
static bool local_command(const char *command, PQExpBufferData *outputbuf);
|
||||
|
||||
static void format_db_cli_params(const char *conninfo, char *output);
|
||||
static bool copy_file(const char *old_filename, const char *new_filename);
|
||||
|
||||
@@ -172,6 +174,7 @@ static char pg_bindir[MAXLEN] = "";
|
||||
static char repmgr_slot_name[MAXLEN] = "";
|
||||
static char *repmgr_slot_name_ptr = NULL;
|
||||
static char path_buf[MAXLEN] = "";
|
||||
static char barman_command_buf[MAXLEN] = "";
|
||||
|
||||
/* Collate command line errors and warnings here for friendlier reporting */
|
||||
ItemList cli_errors = { NULL, NULL };
|
||||
@@ -2054,8 +2057,8 @@ do_standby_clone(void)
|
||||
* Check that there is at least one valid backup
|
||||
*/
|
||||
|
||||
maxlen_snprintf(command, "ssh %s barman show-backup %s latest > /dev/null",
|
||||
options.barman_server,
|
||||
maxlen_snprintf(command, "%s show-backup %s latest > /dev/null",
|
||||
make_barman_ssh_command(),
|
||||
options.cluster_name);
|
||||
command_ok = local_command(command, NULL);
|
||||
if (command_ok == false)
|
||||
@@ -2070,8 +2073,8 @@ do_standby_clone(void)
|
||||
* Locate Barman's backup directory
|
||||
*/
|
||||
|
||||
maxlen_snprintf(command, "ssh %s barman show-server %s | grep 'backup_directory'",
|
||||
options.barman_server,
|
||||
maxlen_snprintf(command, "%s show-server %s | grep 'backup_directory'",
|
||||
make_barman_ssh_command(),
|
||||
options.cluster_name);
|
||||
|
||||
initPQExpBuffer(&command_output);
|
||||
@@ -2126,8 +2129,8 @@ do_standby_clone(void)
|
||||
char output[MAXLEN];
|
||||
int n;
|
||||
|
||||
maxlen_snprintf(command, "ssh %s barman list-files --target=data %s latest",
|
||||
options.barman_server,
|
||||
maxlen_snprintf(command, "%s list-files --target=data %s latest",
|
||||
make_barman_ssh_command(),
|
||||
options.cluster_name);
|
||||
|
||||
fi = popen(command, "r");
|
||||
@@ -6437,6 +6440,26 @@ make_pg_path(char *file)
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
make_barman_ssh_command(void)
|
||||
{
|
||||
static char config_opt[MAXLEN] = "";
|
||||
|
||||
if(strlen(options.barman_config))
|
||||
maxlen_snprintf(config_opt,
|
||||
" --config=%s",
|
||||
options.barman_config);
|
||||
|
||||
maxlen_snprintf(barman_command_buf,
|
||||
"ssh %s barman%s",
|
||||
options.barman_server,
|
||||
config_opt);
|
||||
|
||||
return barman_command_buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
exit_with_errors(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user