From d529bc12efdbecc95f918e2ac93471db3cc0ef20 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 19 Jul 2016 18:24:51 -0700 Subject: [PATCH] pg_backup_and_purge: Fix hardcoding of postgres version. --- puppet/zulip/files/postgresql/pg_backup_and_purge.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/puppet/zulip/files/postgresql/pg_backup_and_purge.py b/puppet/zulip/files/postgresql/pg_backup_and_purge.py index 1cde564439..85506be14f 100644 --- a/puppet/zulip/files/postgresql/pg_backup_and_purge.py +++ b/puppet/zulip/files/postgresql/pg_backup_and_purge.py @@ -6,6 +6,7 @@ import sys sys.path.append('/home/zulip/deployments/current') import scripts.lib.setup_path_on_import +import glob import subprocess import sys import logging @@ -36,7 +37,12 @@ def run(args, dry_run=False): if run(['psql', '-t', '-c', 'select pg_is_in_recovery()']).strip() != 'f': sys.exit(0) -run(['env-wal-e', 'backup-push', '/var/lib/postgresql/9.1/main']) +pg_data_paths = glob.glob('/var/lib/postgresql/*/main') +if len(pg_data_paths) != 1: + print("Postgres installation is not unique: %s" % (pg_data_paths,)) + sys.exit(1) +pg_data_path = pg_data_paths[0] +run(['env-wal-e', 'backup-push', pg_data_path]) now = datetime.now(tz=pytz.utc) with open('/var/lib/nagios_state/last_postgres_backup', 'w') as f: