Mercurial > public > ssdt-docker
diff scripts/backup-container-docker.sh @ 607:3ec3180d23a4
merge
author | Justin Kleinknecht <justin.kleinknecht@mcoecn.org> |
---|---|
date | Tue, 01 Jul 2025 20:51:22 +0100 |
parents | fb25711eead7 |
children |
line wrap: on
line diff
--- a/scripts/backup-container-docker.sh Tue Jul 01 20:50:56 2025 +0100 +++ b/scripts/backup-container-docker.sh Tue Jul 01 20:51:22 2025 +0100 @@ -1,5 +1,5 @@ #!/bin/bash -# Executes a database backup for the specifed database container. +# Executes a database backup for the specified database container. # The current directory is expected to contain a project configured # as with SSDT conventions for an application database. # @@ -64,7 +64,15 @@ } entityId=$(prop 'entityId' | tr -d '"') containerName="$entityId-ess-db" - backupFile=./backup/${entityId}-ess-db.$(date +%Y-%m-%d-%H-%M-%S).backup + IRN=$(docker exec $containerName psql --username=postgres --dbname=$container -t -c 'select irn from organization') + ## if database is empty, it will put IRN 000000 + if [ "$IRN" == "" ]; then + echo "no IRN set, using 000000" + IRN=000000 + fi + ##Take out the extra space from IRN returned from db. + IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` + backupFile=./backup/${IRN}${entityId}-ess-db.$(date +%Y-%m-%d-%H-%M-%S).backup echo "entityId is $entityId" echo "container name is $containerName" fi