Skip to content

Commit b0d72f4

Browse files
authored
Merge pull request #494 from vpodzime/master-upgrade_from_3_12
Refactor how we check if PostgreSQL should be prepared for migration
2 parents f55738d + 231844a commit b0d72f4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packaging/common/cfengine-hub/preinstall.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ if is_upgrade; then
1515
fi
1616
fi
1717

18-
BACKUP_DIR=$PREFIX/backup-before-postgres11-migration
19-
2018
# If upgrading from a version below 3.13 that has PostgreSQL, and the data dir exists.
2119
if is_upgrade && egrep '^3\.([6-9]|1[012])\.' "$PREFIX/UPGRADED_FROM.txt" >/dev/null && [ -d "$PREFIX/state/pg/data" ]; then
20+
alias migrating_postgres='true'
21+
else
22+
alias migrating_postgres='false'
23+
fi
24+
25+
BACKUP_DIR=$PREFIX/backup-before-postgres11-migration
26+
27+
if migrating_postgres; then
2228
if [ -d "$BACKUP_DIR/data" ]; then
2329
cf_console echo "Old backup in $BACKUP_DIR already exists. Please remove before attempting upgrade."
2430
exit 1
@@ -125,7 +131,7 @@ if is_upgrade; then
125131
fi
126132
fi
127133

128-
if is_upgrade && egrep '^3\.([6-9]|1[01])\.' "$PREFIX/UPGRADED_FROM.txt" >/dev/null && [ -d "$PREFIX/state/pg/data" ]; then
134+
if migrating_postgres; then
129135
cf_console echo "Moving old data and copying old binaries to $BACKUP_DIR"
130136
# Now that PostgreSQL is shut down, move the old data out of the way.
131137
mkdir -p "$BACKUP_DIR/lib"

0 commit comments

Comments
 (0)