changeset 321:2cb1093f9aef

making changes to remote backup scripts to account for no IRN
author aldrich@ssdt-ohio.org
date Thu, 31 Oct 2019 14:40:02 +0100
parents 58c49a386a11
children 4285b8a2762e
files scripts/backup-container.sh scripts/remote-backup.sh
diffstat 2 files changed, 19 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/backup-container.sh	Thu Oct 31 14:34:53 2019 +0100
+++ b/scripts/backup-container.sh	Thu Oct 31 14:40:02 2019 +0100
@@ -17,6 +17,13 @@
 
 project=$(composeGetProject)
 
+#If the project is empty, we want to stop the process because this is being run from the wrong directory
+
+if [ "$project" == "" ]; then
+   echo "no project available"
+   exit 1
+fi
+
 set -o pipefail
 mkdir -p ./backup
 ##
@@ -33,18 +40,15 @@
 
 backupFile=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup
 
-echo "IRN${IRN}"
+echo "Project is $project"
+echo "Container is $container"
+echo "IRN is $IRN"
 
 echo "backup file ${backupFile}"
 echo "preparing to backup ${container} on current project at ${projectDir}:"
 echo " "
 
-#If the project is empty, we want to stop the process because this is being run from the wrong directory
 
-if [ "$project" == "" ]; then
-   echo "no project available"
-   exit 1
-fi
 
 echo "starting backup of $container for $project"
 docker-compose exec -T $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile}
--- a/scripts/remote-backup.sh	Thu Oct 31 14:34:53 2019 +0100
+++ b/scripts/remote-backup.sh	Thu Oct 31 14:40:02 2019 +0100
@@ -27,6 +27,13 @@
 
 project=$(composeGetProject)
 
+#If the project is empty, we want to stop the process because this is being run from the wrong directory
+if [ "$project" == "" ]; then
+   echo "no project available"
+   exit 1
+fi
+
+
 IRN=$(docker-compose exec -T $container psql --username=postgres --dbname=$container -t -c 'select irn from organization') 
 ##Trim function in postgres didn't work - so take out the extra space this way.
 IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'`
@@ -43,14 +50,11 @@
 echo "Username is $userName"
 echo "IRN is $IRN"
 
+
 backupFile=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup
 backupFile2=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz
 
-#If the project is empty, we want to stop the process because this is being run from the wrong directory
-if [ "$project" == "" ]; then
-   echo "no project available"
-   exit 1
-fi
+
 
 echo "starting backup of $container for $project"
 docker-compose exec -T $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile}