Skip to content

Commit 9ed8e80

Browse files
authored
Merge pull request #11 from silinternational/develop
Release 4.0.1 - Use current DB owner during restore
2 parents d7cc513 + cac33d7 commit 9ed8e80

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM python:3-alpine
1+
# With Python 3.12.4 on Alpine 3.20, s3cmd 2.4.0 fails with an AttributeError.
2+
# See ITSE-1440 for details.
3+
FROM python:3.12.3-alpine
24

35
# Current version of s3cmd is in edge/testing repo
46
RUN echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories

application/restore.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ if [ -z "${result}" ]; then
2424
message="Database "${DB_NAME}" on host "${DB_HOST}" does not exist."
2525
echo "${MYNAME}: INFO: ${message}"
2626
else
27+
message="finding current owner of DB ${DB_NAME}"
28+
echo "${MYNAME}: ${message}"
29+
db_owner=$(psql --host=${DB_HOST} --username=${DB_ROOTUSER} --command='\list' | grep ${DB_NAME} | cut -d '|' -f 2 | sed -e 's/ *//g')
30+
message="Database owner is ${db_owner}"
31+
echo "${MYNAME}: INFO: ${message}"
32+
2733
echo "${MYNAME}: deleting database ${DB_NAME}"
28-
result=$(psql --host=${DB_HOST} --dbname=postgres --username=${DB_USER} --command="DROP DATABASE ${DB_NAME};")
34+
result=$(psql --host=${DB_HOST} --dbname=postgres --username=${db_owner} --command="DROP DATABASE ${DB_NAME};")
2935
if [ "${result}" != "DROP DATABASE" ]; then
3036
message="Drop database command failed: ${result}"
3137
echo "${MYNAME}: FATAL: ${message}"

0 commit comments

Comments
 (0)