changeset 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 1f4f55e18888
files scripts/backup-container-docker.sh scripts/backup-workflow.sh scripts/exec-all-projects-docker.sh
diffstat 3 files changed, 31 insertions(+), 25 deletions(-) [+]
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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/backup-workflow.sh	Mon Oct 25 12:48:35 2021 -0400
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
+${SSDT_SCRIPTS}/backup-container-docker.sh workflowdb ${1}
--- a/scripts/exec-all-projects-docker.sh	Mon Oct 18 07:05:16 2021 -0400
+++ b/scripts/exec-all-projects-docker.sh	Mon Oct 25 12:48:35 2021 -0400
@@ -1,27 +1,17 @@
 #!/bin/bash
-# Scans for docker projects in specified parent path and
+# Scans for standard SSDT docker projects in specified parent path and
 # executes the specified command.
 #
-# The first parameter specifices theparent directory to search for 
-# docker-compose.yml # files must be specified.  #
+# The first parameter specifices the parent directory to search for. 
 # 
-# the second paramter specifies the command to execute against each
-# compose project.
+# The second parameter specifies the command to execute against each
+# SSDT standard docker project found under the parent directory.
 #
 # examples:
 #
-#   /ssdt/scripts/exec-all-projects.sh /data/prod docker-compose ps
-# 
-#     executes "docker-compose ps" against all projects under /data/prod
-#
-#   /ssdt/scripts/exec-all-projects.sh /data/prod /ssdt/ /ssdt/scripts/backup-usas.sh
+#   /ssdt/scripts/exec-all-projects-docker.sh /data/prod /ssdt/scripts/backup-inventory.sh
 #
-#     runs backup-usas.sh script against all projects under /data/prod
-#
-#   /ssdt/scripts/exec-all-projects.sh /data/prod "/ssdt/scripts/capture.sh | /ssdt/scripts/send.sh -"
-#
-#       captures the log files from all containers and sends one log file per project 
-#       to the SSDT support server.
+#     runs backup-inventory.sh script against all projects under /data/prod
 #
 ##
 
@@ -40,12 +30,13 @@
    projectdir=`dirname $f`
    project=`basename $projectdir`
    cd $projectdir
-   echo "projectdir is $projectdir"
-   echo -e "----\n$executing $COMMAND on $project \n----"      
+   if ls .env/ssdt-*-shared.properties 1> /dev/null 2>&1; then
+      echo "projectdir is $projectdir"
+      echo -e "----\n$executing $COMMAND on $project \n----"      
 
-   #bash -c "${COMMAND}"
-   echo ""
-
+      bash -c "${COMMAND}"
+      echo ""
+   fi
 done
 
 cd $ORIGINALDIR