Handle dangling pg data folders from previous updates
authorRafael dos Santos Silva <xfalcox@gmail.com>
Wed, 27 May 2020 19:28:43 +0000 (16:28 -0300)
committerRafael dos Santos Silva <xfalcox@gmail.com>
Wed, 27 May 2020 19:28:43 +0000 (16:28 -0300)
launcher
templates/postgres.template.yml

index 2a61c2f7c64c04aaf29a505c3b53ca47e2503f69..c19ab2f143ac6fee40ac0938b956477d4e0f18da 100755 (executable)
--- 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
index 69e135f5c7f9ec587243ba70f93865ac2e0cee3c..1e5784e7eaf647e6b43df8a756754212824fad07 100644 (file)
@@ -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