Skip to content

Commit

Permalink
Store results of restoring db
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Nov 19, 2023
1 parent 1062be1 commit 494a27b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions images/backup-restore/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ backupDB() {
}

restoreDB() {
local RESTORE_FILE="backup.sql.gz"
local CURRENT_DATE=$(date '+%Y%m%d-%H%M')
local LOG_RESULT_FILE="restore_results-${CURRENT_DATE}.log"
local flag=true

while "$flag" = true; do
pg_isready -h ${POSTGRES_HOST} -p 5432 >/dev/null 2>&2 || continue
flag=false
wget -O ${RESTORE_FILE} ${RESTORE_URL_FILE}
echo "Restoring ${RESTORE_URL_FILE} in ${POSTGRES_DB}"
gunzip <${RESTORE_FILE} | psql -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d ${POSTGRES_DB}
gunzip -c <${RESTORE_FILE} | psql -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d ${POSTGRES_DB} | tee ${LOG_RESULT_FILE}
aws s3 cp ${LOG_RESULT_FILE} s3://${AWS_S3_BUCKET}/
echo "Import data to ${POSTGRES_DB} has finished ..."
done
}
Expand Down

0 comments on commit 494a27b

Please sign in to comment.