Skip to content

Commit

Permalink
`pg_isready -h ${G3WSUITE_POSTGRES_HOST} -p ${G3WSUITE_POSTGRES_PORT}…
Browse files Browse the repository at this point in the history
… -d template1`
  • Loading branch information
Raruto authored Jun 18, 2024
1 parent 1939f87 commit 2476e04
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions scripts/makefile/db-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,19 @@ rm .pgpass
##
echo "#!/bin/bash" > pg_restore.sh

# Waiting che creation of new cluster.

for DB in $DB_NAMES; do
cat >> pg_restore.sh << EOF
until pg_isready; do
until pg_isready -h ${G3WSUITE_POSTGRES_HOST} -p ${G3WSUITE_POSTGRES_PORT} -d template1; do
echo "wait 30s until is ready"
sleep 30;
done
psql ${DB_LOGIN} -d template1 -c "DROP DATABASE IF EXISTS ${DB}_1634;"
psql ${DB_LOGIN} -d template1 -c "create database ${DB}_1634;"
psql ${DB_LOGIN} -d template1 -c "CREATE DATABASE ${DB}_1634;"
pg_restore ${DB_LOGIN} -d ${DB}_1634 /var/lib/postgresql/backup/${ID}/${DB}.bck
psql ${DB_LOGIN} -d ${DB}_1634 -c "select postgis_extensions_upgrade();"
psql ${DB_LOGIN} -d ${DB}_1634 -c "SELECT postgis_extensions_upgrade();"
psql ${DB_LOGIN} -d template1 -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname='${DB}';"
psql ${DB_LOGIN} -d template1 -c "drop database ${DB};"
psql ${DB_LOGIN} -d template1 -c "alter database ${DB}_1634 rename to ${DB};"
psql ${DB_LOGIN} -d template1 -c "DROP DATABASE ${DB};"
psql ${DB_LOGIN} -d template1 -c "ALTER DATABASE ${DB}_1634 rename to ${DB};"
EOF
done

Expand Down

0 comments on commit 2476e04

Please sign in to comment.