Mercurial > public > ssdt-docker
comparison 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 |
comparison
equal
deleted
inserted
replaced
320:58c49a386a11 | 321:2cb1093f9aef |
---|---|
25 set -o pipefail | 25 set -o pipefail |
26 mkdir -p ./backup | 26 mkdir -p ./backup |
27 | 27 |
28 project=$(composeGetProject) | 28 project=$(composeGetProject) |
29 | 29 |
30 #If the project is empty, we want to stop the process because this is being run from the wrong directory | |
31 if [ "$project" == "" ]; then | |
32 echo "no project available" | |
33 exit 1 | |
34 fi | |
35 | |
36 | |
30 IRN=$(docker-compose exec -T $container psql --username=postgres --dbname=$container -t -c 'select irn from organization') | 37 IRN=$(docker-compose exec -T $container psql --username=postgres --dbname=$container -t -c 'select irn from organization') |
31 ##Trim function in postgres didn't work - so take out the extra space this way. | 38 ##Trim function in postgres didn't work - so take out the extra space this way. |
32 IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` | 39 IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` |
33 | 40 |
34 ## if database is empty, it will put IRN 000000 | 41 ## if database is empty, it will put IRN 000000 |
41 echo "Container is $container" | 48 echo "Container is $container" |
42 echo "Remote target is $remoteTarget" | 49 echo "Remote target is $remoteTarget" |
43 echo "Username is $userName" | 50 echo "Username is $userName" |
44 echo "IRN is $IRN" | 51 echo "IRN is $IRN" |
45 | 52 |
53 | |
46 backupFile=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup | 54 backupFile=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup |
47 backupFile2=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz | 55 backupFile2=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz |
48 | 56 |
49 #If the project is empty, we want to stop the process because this is being run from the wrong directory | 57 |
50 if [ "$project" == "" ]; then | |
51 echo "no project available" | |
52 exit 1 | |
53 fi | |
54 | 58 |
55 echo "starting backup of $container for $project" | 59 echo "starting backup of $container for $project" |
56 docker-compose exec -T $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile} | 60 docker-compose exec -T $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile} |
57 | 61 |
58 if [[ $( grep --count "CREATE TABLE" ${backupFile} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile} ) -eq 0 ]]; then | 62 if [[ $( grep --count "CREATE TABLE" ${backupFile} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile} ) -eq 0 ]]; then |