Skip to content

Commit 99b5615

Browse files
committed
Change restore script
1 parent e252325 commit 99b5615

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

Scripts/RestoreDB.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ if [ "$LOAD_S3_SECRETS" = "YES" ]; then
55
eval $(aws s3 --region ${SECRETS_BUCKET_REGION} cp s3://${SECRETS_BUCKET_NAME}/${SECRETS_FILE_NAME} - | sed 's/^/export /')
66
fi
77

8-
if [ -f "${PGDATA_BACKUP}" ]; then
9-
gunzip -c ${PGDATA_BACKUP} | psql --dbname=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} 2> ${BACKUP_RESTORE_LOG} && \
10-
rm ${PGDATA_BACKUP}
11-
else
12-
cat /CreateDB.sql | psql --dbname=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} 2> ${BACKUP_RESTORE_LOG}
13-
fi
8+
#load latest database backup
9+
aws s3 --region ${SECRETS_BUCKET_REGION} cp s3://${BACKUPS_BUCKET_NAME}/latest.psql.gz ./latest.psql.gz > ${BACKUP_RESTORE_LOG} 2>&1
10+
#restore backup
11+
gunzip -c ./latest.psql.gz | psql --dbname=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} >> ${BACKUP_RESTORE_LOG} 2>&1 && \
12+
rm ./latest.psql.gz

Scripts/secrets-entrypoint.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
set -e
44

5-
if [ "$LOAD_S3_SECRETS" = "YES" ]; then
6-
# Load the S3 secrets file contents into the environment variables
7-
eval $(aws s3 --region ${SECRETS_BUCKET_REGION} cp s3://${SECRETS_BUCKET_NAME}/${SECRETS_FILE_NAME} - | sed 's/^/export /')
5+
if [ "$RESTORE_BACKUP" = "YES" ]; then
6+
sh /RestoreDB.sh
87
fi
98

109
#migrate database
1110
sh /MigrateDB.sh
1211

12+
if [ "$LOAD_S3_SECRETS" = "YES" ]; then
13+
# Load the S3 secrets file contents into the environment variables
14+
eval $(aws s3 --region ${SECRETS_BUCKET_REGION} cp s3://${SECRETS_BUCKET_NAME}/${SECRETS_FILE_NAME} - | sed 's/^/export /')
15+
fi
16+
1317
exec dotnet SimpleToDoService.dll

0 commit comments

Comments
 (0)