Mercurial > public > ssdt-docker
comparison scripts/backup-container-docker.sh @ 590:80f3564f2553 production v2.20.0
flow: Merged <release> '2.20.0' to <master> ('production').
author | Marc Davis <marc.davis@mcoecn.org> |
---|---|
date | Thu, 05 Sep 2024 15:01:40 -0400 |
parents | fb25711eead7 |
children |
comparison
equal
deleted
inserted
replaced
587:2bd96ab37a7a | 590:80f3564f2553 |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # Executes a database backup for the specifed database container. | 2 # Executes a database backup for the specified database container. |
3 # The current directory is expected to contain a project configured | 3 # The current directory is expected to contain a project configured |
4 # as with SSDT conventions for an application database. | 4 # as with SSDT conventions for an application database. |
5 # | 5 # |
6 # When successful, the output file will be in ./backup with the | 6 # When successful, the output file will be in ./backup with the |
7 # container name and timestamp in the file. The format of the output | 7 # container name and timestamp in the file. The format of the output |
62 function prop { | 62 function prop { |
63 grep "${1}" .env/ess-shared.properties|cut -d'=' -f2 | 63 grep "${1}" .env/ess-shared.properties|cut -d'=' -f2 |
64 } | 64 } |
65 entityId=$(prop 'entityId' | tr -d '"') | 65 entityId=$(prop 'entityId' | tr -d '"') |
66 containerName="$entityId-ess-db" | 66 containerName="$entityId-ess-db" |
67 backupFile=./backup/${entityId}-ess-db.$(date +%Y-%m-%d-%H-%M-%S).backup | 67 IRN=$(docker exec $containerName psql --username=postgres --dbname=$container -t -c 'select irn from organization') |
68 ## if database is empty, it will put IRN 000000 | |
69 if [ "$IRN" == "" ]; then | |
70 echo "no IRN set, using 000000" | |
71 IRN=000000 | |
72 fi | |
73 ##Take out the extra space from IRN returned from db. | |
74 IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` | |
75 backupFile=./backup/${IRN}${entityId}-ess-db.$(date +%Y-%m-%d-%H-%M-%S).backup | |
68 echo "entityId is $entityId" | 76 echo "entityId is $entityId" |
69 echo "container name is $containerName" | 77 echo "container name is $containerName" |
70 fi | 78 fi |
71 | 79 |
72 if [ ! -z "$containerName" ]; then | 80 if [ ! -z "$containerName" ]; then |