comparison scripts/backup-container-docker.sh @ 584:fb25711eead7

add irn to the ess backup
author Marc Davis <marc.davis@mcoecn.org>
date Thu, 05 Sep 2024 14:38:06 -0400
parents 579a61f2037d
children
comparison
equal deleted inserted replaced
583:646ecb227dbc 584:fb25711eead7
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