diff --git a/docs/multisite.rst b/docs/multisite.rst index a0ca9de8d..5cf703e86 100644 --- a/docs/multisite.rst +++ b/docs/multisite.rst @@ -134,6 +134,8 @@ Details of the configuration parameters Time to live of site leader lock. If the site is unable to elect a functioning leader within this timeout, a different site can take over the leader role. Must be a few times longer than the usual ``ttl`` value in order to prevent unnecessary site failovers. ``retry_timeout`` How long the global etcd cluster can be inaccessible before the cluster is demoted. Must be a few times longer than the usual ``retry_timeout`` value in order to prevent unnecessary site failovers. +``restore_command`` + PostgreSQL restore\_command to use to fetch WAL files from remote site. Passwords in the YAML configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/patroni/multisite.py b/patroni/multisite.py index 2ca07db8a..af4b5e9ad 100644 --- a/patroni/multisite.py +++ b/patroni/multisite.py @@ -184,6 +184,14 @@ def _replication_slot(self) -> Optional[str]: site_config = global_config.sites.get(self.name) return site_config and site_config.get('slot') + @property + def _restore_command(self) -> Optional[str]: + site_config = global_config.sites.get(self.name) + if site_config and 'restore_command' in site_config: + return site_config['restore_command'] + + return self.config.get('restore_command') + def _disconnected_operation(self): self._standby_config = {'restore_command': 'false'} @@ -207,6 +215,11 @@ def _set_standby_config(self, other: Member): slot = self._replication_slot if slot: new_config['primary_slot_name'] = slot + + restore_command = self._restore_command + if restore_command: + new_config['restore_command'] = restore_command + old_conf, self._standby_config = self._standby_config, new_config except KeyError: old_conf = self._standby_config