Handle dangling pg data folders from previous updates

Handle dangling pg data folders from previous updates

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

GitHub sha: b20ba9ee

1 Like