Skip to content

Commit

Permalink
Merge pull request #11 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 4.0.1 - Use current DB owner during restore
  • Loading branch information
dalenewby authored Aug 20, 2024
2 parents d7cc513 + cac33d7 commit 9ed8e80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM python:3-alpine
# With Python 3.12.4 on Alpine 3.20, s3cmd 2.4.0 fails with an AttributeError.
# See ITSE-1440 for details.
FROM python:3.12.3-alpine

# Current version of s3cmd is in edge/testing repo
RUN echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
Expand Down
8 changes: 7 additions & 1 deletion application/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ if [ -z "${result}" ]; then
message="Database "${DB_NAME}" on host "${DB_HOST}" does not exist."
echo "${MYNAME}: INFO: ${message}"
else
message="finding current owner of DB ${DB_NAME}"
echo "${MYNAME}: ${message}"
db_owner=$(psql --host=${DB_HOST} --username=${DB_ROOTUSER} --command='\list' | grep ${DB_NAME} | cut -d '|' -f 2 | sed -e 's/ *//g')
message="Database owner is ${db_owner}"
echo "${MYNAME}: INFO: ${message}"

echo "${MYNAME}: deleting database ${DB_NAME}"
result=$(psql --host=${DB_HOST} --dbname=postgres --username=${DB_USER} --command="DROP DATABASE ${DB_NAME};")
result=$(psql --host=${DB_HOST} --dbname=postgres --username=${db_owner} --command="DROP DATABASE ${DB_NAME};")
if [ "${result}" != "DROP DATABASE" ]; then
message="Drop database command failed: ${result}"
echo "${MYNAME}: FATAL: ${message}"
Expand Down

0 comments on commit 9ed8e80

Please sign in to comment.