diff scripts/remote-backup.sh @ 320:58c49a386a11

making changes to remote backup scripts to create directory
author aldrich@ssdt-ohio.org
date Thu, 31 Oct 2019 14:34:53 +0100
parents 7c460a921709
children 2cb1093f9aef
line wrap: on
line diff
--- a/scripts/remote-backup.sh	Thu Oct 31 11:40:53 2019 +0100
+++ b/scripts/remote-backup.sh	Thu Oct 31 14:34:53 2019 +0100
@@ -31,6 +31,12 @@
 ##Trim function in postgres didn't work - so take out the extra space this way.
 IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'`
 
+## if database is empty, it will put IRN 000000
+if [ "$IRN" == "" ]; then
+   echo "no IRN set, using 000000"
+    IRN=000000
+fi
+
 echo "Project is $project"
 echo "Container is $container"
 echo "Remote target is $remoteTarget"
@@ -40,7 +46,7 @@
 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
@@ -51,8 +57,10 @@
 
 if [[ $( grep --count "CREATE TABLE" ${backupFile} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile} ) -eq 0 ]]; then
    echo "ERROR: backup verification FAILED"
+   echo "Error: empty database"
    echo "ERROR:  $(tail ${backupFile})"
-   exit 1
+  # We want the process to continue even if the db is blank
+  # exit 1
 fi
 
 gzip ${backupFile}