- if [ ! "9.5" = "$PG_MAJOR_OLD" ]; then
- echo Upgrading PostgreSQL to from version ${PG_MAJOR_OLD} to 9.5
+ if [ ! "10" = "$PG_MAJOR_OLD" ]; then
+ echo Upgrading PostgreSQL from version ${PG_MAJOR_OLD} to 10
+ free_disk=$(df /var | tail -n 1 | awk '{print $4}')
+ required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))
+
+ if [ "$free_disk" -lt "$required" ]; then
+ echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"
+ echo "Please free up some space, or expand your disk, before continuing."
+ echo ''
+ echo 'To avoid upgrading change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml" in containers/app.yml'
+ exit 1
+ fi
+