Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.2.1 - Use current DB owner during restore #4

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
mtompset marked this conversation as resolved.
Show resolved Hide resolved
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