diff scripts/backup-container-docker.sh @ 390:d75786228e6b

INV-197 wire workflows backup into shared scripts
author Matt Calmes <calmes@ssdt-ohio.org>
date Mon, 25 Oct 2021 12:48:35 -0400
parents 4e42c10e3c0d
children 56498d910235
line wrap: on
line diff
--- a/scripts/backup-container-docker.sh	Mon Oct 18 07:05:16 2021 -0400
+++ b/scripts/backup-container-docker.sh	Mon Oct 25 12:48:35 2021 -0400
@@ -24,6 +24,11 @@
    entityId=$(prop 'entityId' | tr -d '"')
    containerName="$entityId-inventory-db"
    IRN=$(docker exec $containerName psql --username=postgres --dbname=$container -t -c 'select districtirn from inventoryconfiguration')
+   ## 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}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup
@@ -31,10 +36,15 @@
    echo "container name is $containerName"
 fi
 
-## if database is empty, it will put IRN 000000
-if [ "$IRN" == "" ]; then
-   echo "no IRN set,using 000000"
-    IRN=000000
+if [ "$container" = "workflowsdb" ]; then
+   function prop {
+       grep "${1}" .env/ssdt-workflows-shared.properties|cut -d'=' -f2
+   }
+   entityId=$(prop 'entityId' | tr -d '"')
+   containerName="$entityId-workflows-db"
+   backupFile=./backup/${entityId}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup
+   echo "entityId is $entityId"
+   echo "container name is $containerName"
 fi
 
 echo "Container is $container"