From b20ba9ee11b5098b9c39cd46e9f462d14ac6ce60 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Wed, 27 May 2020 16:28:43 -0300 Subject: [PATCH] Handle dangling pg data folders from previous updates --- launcher | 2 +- templates/postgres.template.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/launcher b/launcher index 2a61c2f..c19ab2f 100755 --- a/launcher +++ b/launcher @@ -487,7 +487,7 @@ fi if [[ $REPLY =~ ^[Yy]$ ]]; then echo "removing old PostgreSQL data cluster at /var/discourse/shared/standalone/postgres_data_old..." - rm -rf /var/discourse/shared/standalone/postgres_data_old + rm -rf /var/discourse/shared/standalone/postgres_data_old* else exit 1 fi diff --git a/templates/postgres.template.yml b/templates/postgres.template.yml index 69e135f..1e5784e 100644 --- a/templates/postgres.template.yml +++ b/templates/postgres.template.yml @@ -73,6 +73,10 @@ run: exit 1 fi + if [ -d /shared/postgres_data_old ]; then + mv /shared/postgres_data_old /shared/postgres_data_older + fi + rm -fr /shared/postgres_data_new install -d -m 0755 -o postgres -g postgres /shared/postgres_data_new && sudo -u postgres /usr/lib/postgresql/12/bin/initdb -D /shared/postgres_data_new || exit 0 apt-get update -- 2.25.1