"standby clone": add --recovery-conf-only option

This will generate "recovery.conf" for an existing standby.

Typical use-case is a standby cloned manually from an external data
source (e.g. Barman), where "recovery.conf" needs to be created
(and if required a replication slot).

The --dry-run option will check the pre-requisites but not actually
create "recovery.conf" or a replication slot.

This requires that the upstream node is running, a replication connection
can be made and if required a replication slot can be created.

Implements GitHub #382.
This commit is contained in:
Ian Barwick
2018-02-21 14:37:01 +09:00
parent 829cf5cca4
commit 3a764f678a
5 changed files with 424 additions and 25 deletions

View File

@@ -388,6 +388,11 @@ main(int argc, char **argv)
runtime_options.without_barman = true;
break;
case OPT_RECOVERY_CONF_ONLY:
runtime_options.recovery_conf_only = true;
break;
/*---------------------------
* "standby register" options
*---------------------------
@@ -1014,10 +1019,7 @@ main(int argc, char **argv)
/*
* Check for configuration file items which can be overriden by runtime
* options
*/
/*
* ============================================================================
* =====================================================================
*/
/*
@@ -1495,19 +1497,6 @@ check_cli_parameters(const int action)
}
}
if (runtime_options.event[0])
{
switch (action)
{
case CLUSTER_EVENT:
break;
default:
item_list_append_format(&cli_warnings,
_("--event not required when executing %s"),
action_name(action));
}
}
if (runtime_options.replication_user[0])
{
switch (action)
@@ -1527,6 +1516,32 @@ check_cli_parameters(const int action)
}
}
if (runtime_options.recovery_conf_only == true)
{
switch (action)
{
case STANDBY_CLONE:
break;
default:
item_list_append_format(&cli_warnings,
_("--create-recovery-conf will be ignored when executing %s"),
action_name(action));
}
}
if (runtime_options.event[0])
{
switch (action)
{
case CLUSTER_EVENT:
break;
default:
item_list_append_format(&cli_warnings,
_("--event not required when executing %s"),
action_name(action));
}
}
if (runtime_options.limit_provided)
{
switch (action)