|
|
|
|
@ -3,21 +3,37 @@
|
|
|
|
|
RESTORE_DUMP_GZ=2023-09-06_aactdb_with_matches.sql.gz
|
|
|
|
|
POSTGRES_USER=root
|
|
|
|
|
POSTGRES_PASSWORD=root
|
|
|
|
|
POSTGRES_DB=aact_db
|
|
|
|
|
|
|
|
|
|
#start container
|
|
|
|
|
podman run \
|
|
|
|
|
-e POSTGRES_PASSWORD="${POSTGRES_PASSWORD}" \
|
|
|
|
|
-e POSTGRES_USER="${POSTGRES_USER}" \
|
|
|
|
|
-e POSTGRES_DB=aact_db \
|
|
|
|
|
--name aact_db \
|
|
|
|
|
--detatch \
|
|
|
|
|
-e POSTGRES_DB="${POSTGRES_DB}" \
|
|
|
|
|
--name "${POSTGRES_DB}" \
|
|
|
|
|
--detach \
|
|
|
|
|
--shm-size=512mb \
|
|
|
|
|
--volume ${RESTORE_DUMP_GZ}:/backup/${RESTORE_DUMP_GZ} \
|
|
|
|
|
--ports 5432:5432\
|
|
|
|
|
--volume ./backup/:/backup/ \
|
|
|
|
|
-p 5432:5432\
|
|
|
|
|
postgres:14-alpine
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sleep 10
|
|
|
|
|
|
|
|
|
|
#execute within container
|
|
|
|
|
podman exec aact_db \
|
|
|
|
|
"gzip --keep --stdout --decompress /backup/2023-09-06_aactdb_with_matches.sql.gz | psql -U ${POSTGRES_USER}"
|
|
|
|
|
# Function to check if PostgreSQL is ready
|
|
|
|
|
function check_postgres {
|
|
|
|
|
podman exec -i "${POSTGRES_DB}" psql -h localhost -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c '\q' > /dev/null 2>&1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Wait for PostgreSQL to be ready
|
|
|
|
|
until check_postgres; do
|
|
|
|
|
echo "Waiting for PostgreSQL to be ready..."
|
|
|
|
|
sleep 4
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "PostgreSQL is ready. Restoring the database..."
|
|
|
|
|
|
|
|
|
|
# Decompress the dump file and restore it to the database
|
|
|
|
|
podman exec -i "${POSTGRES_DB}" sh -c "gunzip -c /backup/${RESTORE_DUMP_GZ} | psql -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}"
|
|
|
|
|
|
|
|
|
|
echo "Database restoration complete."
|
|
|
|
|
|