Mercurial > public > ssdt-docker
diff scripts/remote-backup-all.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 | 4285b8a2762e |
line wrap: on
line diff
--- a/scripts/remote-backup-all.sh Thu Oct 31 11:40:53 2019 +0100 +++ b/scripts/remote-backup-all.sh Thu Oct 31 14:34:53 2019 +0100 @@ -29,11 +29,14 @@ 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 +## first will try to get IRNfrom usasdb; if that is empty it will try to get it from uspsdb IRN=$(docker-compose exec -T $container1 psql --username=postgres --dbname=$container1 -t -c 'select irn from organization') @@ -44,6 +47,12 @@ ##Trim function in postgres didn't work - so take out the extra space this way. IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` +## if both database are empty, it will put IRN 000000 +if [ "$IRN" == "" ]; then + echo "no IRN set, using 000000" + IRN=000000 +fi + echo "project is $project" echo "Containers are $container1 and $container2" echo "Remote target is $remoteTarget" @@ -62,7 +71,8 @@ if [[ $( grep --count "CREATE TABLE" ${backupFile1} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile1} ) -eq 0 ]]; then echo "ERROR: backup verification FAILED" echo "ERROR: $(tail ${backupFile1})" - else + echo "Error: empty database" + #else We still gzip the backup file gzip ${backupFile1} echo "completed backup of $container1 for $project to ${backupFile1}" @@ -79,7 +89,8 @@ if [[ $( grep --count "CREATE TABLE" ${backupFile2} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile2} ) -eq 0 ]]; then echo "ERROR: backup verification FAILED" echo "ERROR: $(tail ${backupFile2})" - else + echo "Error: empty database" + #else We still gzip the backup file gzip ${backupFile2} echo "completed backup of $container2 for $project to ${backupFile2}"