Skip to content

Commit 6fd28e1

Browse files
committed
fix: Unify upgrade scripts
1 parent 534e633 commit 6fd28e1

File tree

4 files changed

+15
-143
lines changed

4 files changed

+15
-143
lines changed

devops/upgrade_pg/upgrade-11-to-13.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

devops/upgrade_pg/upgrade-11-to-14.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

devops/upgrade_pg/upgrade-13-to-14.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

devops/upgrade_pg/upgrade.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
docker stop lms_db_1
22

33
# Put values here if you've configured them before
4-
# DB_NAME=lms
5-
# DB_USERNAME=lmsweb
6-
# DB_PASSWORD=
4+
CURRENT_VERSION=11
5+
NEW_VERSION=14
6+
DB_NAME=lms
7+
DB_USERNAME=lmsweb
8+
DB_PASSWORD=
9+
10+
echo "Remove these two lines to indicate you have filled the details"
11+
return 1
712

813
CURRENT_DATE=$(date +%d-%m-%Y_%H_%M_%S)
914
MOUNT_PATH=/pg_data
10-
PG_OLD_DATA=/pg_data/11/data
11-
PG_NEW_DATA=/pg_data/13/data
12-
BACKUP_FILENAME=v11.$CURRENT_DATE.sql
15+
PG_OLD_DATA=/pg_data/${CURRENT_VERSION}/data
16+
PG_NEW_DATA=/pg_data/${NEW_VERSION}/data
17+
BACKUP_FILENAME=v${CURRENT_VERSION}.${CURRENT_DATE}.sql
1318
BACKUP_PATH=$MOUNT_PATH/backup/$BACKUP_FILENAME
1419
BACKUP_DIR=$(dirname "$BACKUP_PATH")
1520
VOLUME_NAME=lms_db-data-volume
@@ -20,7 +25,7 @@ docker run --rm -v $VOLUME_NAME:$MOUNT_PATH \
2025
-e POSTGRES_DB="${DB_NAME:-db}" \
2126
-e POSTGRES_USER="${DB_USERNAME:-postgres}" \
2227
-e POSTGRES_PASSWORD="${DB_PASSWORD:-postgres}" \
23-
postgres:11-alpine \
28+
postgres:${CURRENT_VERSION}-alpine \
2429
/bin/bash -c "chown -R postgres:postgres $MOUNT_PATH \
2530
&& su - postgres /bin/bash -c \"/usr/local/bin/pg_ctl -D \\\"\$PGDATA\\\" start\" \
2631
&& mkdir -p \"$BACKUP_DIR\" \
@@ -33,7 +38,7 @@ docker run --rm -v $VOLUME_NAME:$MOUNT_PATH \
3338
-e POSTGRES_DB="${DB_NAME:-db}" \
3439
-e POSTGRES_USER="${DB_USERNAME:-postgres}" \
3540
-e POSTGRES_PASSWORD="${DB_PASSWORD:-postgres}" \
36-
postgres:13-alpine \
41+
postgres:$NEW_VERSION-alpine \
3742
/bin/bash -c "ls -la \"$BACKUP_DIR\" \
3843
&& mkdir -p \"\$PGDATA\" \
3944
&& chown -R postgres:postgres \"\$PGDATA\" \
@@ -43,3 +48,5 @@ docker run --rm -v $VOLUME_NAME:$MOUNT_PATH \
4348
&& su - postgres -c \"psql -f $BACKUP_PATH\" \
4449
&& printf \"\\\nhost all all all md5\\\n\" >> \"\$PGDATA/pg_hba.conf\" \
4550
"
51+
echo "Upgrade finished. Check for bad log messages. If none found, rerun:"
52+
echo "source ./build.sh && source ./start.sh && source ./bootstrap.sh"

0 commit comments

Comments
 (0)