patroni/debian/patches/avoid_overwriting_configuration_during_boostrap.patch
Michael Banck bb19fd1462 * debian/patches/avoid_overwriting_configuration_during_boostrap.patch: New
patch, avoids streaming a backup of the primary's postgresql.conf file
    during bootstrap, overwriting the standby's postgresql.base.conf and
    possible preventing PostgreSQL to start up.
2022-07-29 15:02:46 +02:00

42 lines
2 KiB
Diff

commit a3776e0dfb2f0c5a9e5174f948122b8fb33ceebc
Author: Michael Banck <michael.banck@credativ.de>
Date: Fri Jul 29 14:55:15 2022 +0200
Make backup copies of configuration files in config_dir.
Before, the .backup files were always done in the data directory. However, if
there is a distinct configuration directory, it seems logical to put them
there. If config_dir is not configured, it defaults back to the data directory,
so this will not change things for setups where postgresql.conf is in the data
directory.
On the other hand, it will help with setups where postgresql.conf is outside
the data directory and has local changes. In this case, those no longer get
overwritten on boostrap/clone from the primary's backup configuration file that
is streamed to the boostrapped node.
Close #2370
diff --git a/patroni/postgresql/config.py b/patroni/postgresql/config.py
index 9314315..976cf48 100644
--- a/patroni/postgresql/config.py
+++ b/patroni/postgresql/config.py
@@ -362,7 +362,7 @@ class ConfigHandler(object):
try:
for f in self._configuration_to_save:
config_file = os.path.join(self._config_dir, f)
- backup_file = os.path.join(self._postgresql.data_dir, f + '.backup')
+ backup_file = os.path.join(self._config_dir, f + '.backup')
if os.path.isfile(config_file):
shutil.copy(config_file, backup_file)
except IOError:
@@ -374,7 +374,7 @@ class ConfigHandler(object):
try:
for f in self._configuration_to_save:
config_file = os.path.join(self._config_dir, f)
- backup_file = os.path.join(self._postgresql.data_dir, f + '.backup')
+ backup_file = os.path.join(self._config_dir, f + '.backup')
if not os.path.isfile(config_file):
if os.path.isfile(backup_file):
shutil.copy(backup_file, config_file)