I upgraded to latest and lost everything

So i have checked the postgres template file. It is targeting only one db. Which is insane. It should have looped through the databases present and changed them. I leaving this here for anybody looking for a solution in this scenario

DB_LIST=$(su postgres -c "/usr/lib/postgresql/${PG_MAJOR_OLD}/bin/psql -p 5432 -tAc \"select datname from pg_database where not datistemplate and datname != 'postgres'\"")

for DB in $DB_LIST; do
  su postgres -c "/usr/lib/postgresql/${PG_MAJOR_OLD}/bin/pg_dump -Fd -j$(nproc --ignore=1) \"$DB\" -f /shared/postgres_dump/\"$DB\""
done