diff scripts/remote-backup.sh @ 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
line wrap: on
line diff
--- 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}