Mercurial > public > ssdt-docker
annotate scripts/remote-backup.sh @ 499:d51e12ec50cd
USASR-5154 remove postgres install
author | belknapSSDT <zach.belknap@mcoecn.org> |
---|---|
date | Fri, 29 Sep 2023 11:49:41 -0400 |
parents | 4285b8a2762e |
children |
rev | line source |
---|---|
287 | 1 #!/bin/bash |
2 # Executes a database backup for the specified database container. | |
3 # The current directory is expected to contain a project configured | |
4 # as with SSDT conventions for an application database. | |
5 # | |
6 # When successful, the output file will be in ./backup with the | |
7 # container name and timestamp in the file. | |
8 # The file will also be placed on the specified remote target | |
9 # The format of the output is a compressed pg_dump (sql) format. | |
10 # along with the top level contents of the project directory | |
11 # Environment variables can be used for REMOTE_BACKUP_TARGET and REMOTE_USERNAME | |
12 # | |
13 | |
14 | |
15 container=${1?Must provide container name to backup} | |
16 remoteTarget=${2:-$REMOTE_BACKUP_TARGET} | |
17 userName=${3:-$REMOTE_USERNAME} | |
18 projectDir=${4:-$PWD} | |
19 | |
20 | |
21 cd $projectDir | |
22 | |
23 source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh" | |
24 | |
25 set -o pipefail | |
26 mkdir -p ./backup | |
27 | |
28 project=$(composeGetProject) | |
29 | |
321
2cb1093f9aef
making changes to remote backup scripts to account for no IRN
aldrich@ssdt-ohio.org
parents:
320
diff
changeset
|
30 #If the project is empty, we want to stop the process because this is being run from the wrong directory |
2cb1093f9aef
making changes to remote backup scripts to account for no IRN
aldrich@ssdt-ohio.org
parents:
320
diff
changeset
|
31 if [ "$project" == "" ]; then |
2cb1093f9aef
making changes to remote backup scripts to account for no IRN
aldrich@ssdt-ohio.org
parents:
320
diff
changeset
|
32 echo "no project available" |
2cb1093f9aef
making changes to remote backup scripts to account for no IRN
aldrich@ssdt-ohio.org
parents:
320
diff
changeset
|
33 exit 1 |
2cb1093f9aef
making changes to remote backup scripts to account for no IRN
aldrich@ssdt-ohio.org
parents:
320
diff
changeset
|
34 fi |
2cb1093f9aef
making changes to remote backup scripts to account for no IRN
aldrich@ssdt-ohio.org
parents:
320
diff
changeset
|
35 |
2cb1093f9aef
making changes to remote backup scripts to account for no IRN
aldrich@ssdt-ohio.org
parents:
320
diff
changeset
|
36 |
314 | 37 IRN=$(docker-compose exec -T $container psql --username=postgres --dbname=$container -t -c 'select irn from organization') |
38 ##Trim function in postgres didn't work - so take out the extra space this way. | |
39 IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` | |
40 | |
320
58c49a386a11
making changes to remote backup scripts to create directory
aldrich@ssdt-ohio.org
parents:
319
diff
|