From a7af88edb3840615c99f9d5380801fa9d88151e7 Mon Sep 17 00:00:00 2001 From: Justin Clift Date: Mon, 30 Sep 2024 21:21:52 +1000 Subject: [PATCH] WIP. Get the list of databases in the database cluster --- docker-entrypoint.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4f5d90a..49b3eca 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -540,7 +540,7 @@ _main() { echo "Running pg_upgrade command, from $(pwd)" echo "---------------------------------------" bin_path=$(get_bin_path) - ${bin_path}/pg_upgrade --username="${POSTGRES_USER}" --link -d "${OLD}" -D "${NEW}" -b "${OLDPATH}/bin" -B "${bin_path}" --socketdir="/var/run/postgresql" + "${bin_path}/pg_upgrade" --username="${POSTGRES_USER}" --link -d "${OLD}" -D "${NEW}" -b "${OLDPATH}/bin" -B "${bin_path}" --socketdir="/var/run/postgresql" echo "--------------------------------------" echo "Running pg_upgrade command is complete" echo "--------------------------------------" @@ -578,14 +578,11 @@ _main() { echo "Reindexing the databases" echo "------------------------" - # Start the database in single user mode - "${OLDPATH}/bin/postgres" --single -D "${POSTGRES_DB}" - # 1. Get the list of databases in the database cluster - # Something like this should work: - # SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE; + DB_LIST=$(echo 'SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE' | postgres --single -D /var/lib/postgresql/data 2>bar | grep datname | grep -v backend | cut -d '"' -f 2) # 2. For each database, get the list of indexes + # 3. Regenerate the indexes echo "-------------------------------"