Mercurial > public > ssdt-docker
changeset 293:95d7d70f34a5 production v2.4.0
flow: Merged <release> 'v2.4.0' to <master> ('production').
author | smith@nwoca.org |
---|---|
date | Thu, 27 Dec 2018 00:06:14 +0000 |
parents | cd2e677afa4e (current diff) 56689baf0bf6 (diff) |
children | a49f7cad8899 |
files | pilot/import-usas.sh pilot/import-usas.yml pilot/import-usps.sh pilot/import-usps.yml pilot/nginx-override.yml pilot/setup.sh pilot/training.sh pilot/training.yml pilot/usas-services.yml pilot/usps-services.yml |
diffstat | 17 files changed, 176 insertions(+), 508 deletions(-) [+] |
line wrap: on
line diff
--- a/bamboo-agent/Dockerfile Thu Nov 15 20:10:48 2018 +0000 +++ b/bamboo-agent/Dockerfile Thu Dec 27 00:06:14 2018 +0000 @@ -38,7 +38,7 @@ && apt-get install -y zip -ENV ANT_VERSION 1.10.3 +ENV ANT_VERSION 1.10.5 RUN cd && \ curl -fL -o apache-ant-bin.tar.gz http://www.us.apache.org/dist//ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ tar -xzf apache-ant-bin.tar.gz && \
--- a/java/Dockerfile Thu Nov 15 20:10:48 2018 +0000 +++ b/java/Dockerfile Thu Dec 27 00:06:14 2018 +0000 @@ -1,4 +1,4 @@ -FROM openjdk:8u121-jdk +FROM openjdk:8u181-jdk MAINTAINER Dave Smith <smith@nwoca.org>
--- a/pilot/import-usas.sh Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#!/bin/bash - -source "$( dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" - -docker-compose stop usasapp usasdb -resetDbVolume usasdb -docker-compose rm -vf usasapp usasdb - -export IMP_IRN=${IMP_IRN} -export IMP_URL=${IMP_URL-ftp://username:password@nwoca.org} -export IMP_PATH=${IMP_PATH} - -[ -f "docker-compose.override.yml" ] && export OVERRIDE=" -f docker-compose.override.yml" -[ -f "docker-compose.usasimport.override.yml" ] && export OVERRIDE2=" -f docker-compose.usasimport.override.yml" -# -docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usas.yml $OVERRIDE rm -f usasimport -# start import and wait for completion -docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usas.yml $OVERRIDE $OVERRIDE2 up usasimport | tee usasimport.log -# remove temporary container -docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usas.yml $OVERRIDE rm -f usasimport -# start application -docker-compose up -d usasapp -
--- a/pilot/import-usas.yml Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -version: "3.3" -services: - usasimport: - image: docker.ssdt.io/usas-import:${USAS_TAG:-pilot} - command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- } - depends_on: - - usasdb - environment: - - DB_HOST=usasdb - - DB_NAME=usasdb - - DB_USER=usas - - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} \ No newline at end of file
--- a/pilot/import-usps.sh Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#!/bin/bash - -source "$( dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" - -docker-compose stop uspsapp uspsdb -resetDbVolume uspsdb -docker-compose rm -vf uspsapp uspsdb - -export IMP_IRN=${IMP_IRN} -export IMP_URL=${IMP_URL-ftp://username:password@nwoca.org} -export IMP_PATH=${IMP_PATH} -export IMP_ANON=${IMP_ANON:--a false} -export IMP_EM=${IMP_EM-} - -[ -f "docker-compose.override.yml" ] && export OVERRIDE=" -f docker-compose.override.yml" - -docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usps.yml $OVERRIDE rm -f uspsimport -# start import and wait for completion -docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usps.yml $OVERRIDE up uspsimport | tee uspsimport.log -# remove temporary container -docker-compose -f docker-compose.yml -f ${SSDT_HOME}/pilot/import-usps.yml $OVERRIDE rm -f uspsimport -# start application -docker-compose up -d uspsapp
--- a/pilot/import-usps.yml Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -version: "3.3" -services: - uspsimport: - image: docker.ssdt.io/usps-import:${USPS_TAG:-pilot} - command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- } ${IMP_ANON- } ${IMP_EM- } - depends_on: - - uspsdb - environment: - - DB_HOST=uspsdb - - DB_NAME=uspsdb - - DB_USER=usps - - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} - \ No newline at end of file
--- a/pilot/nginx-override.yml Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -version: "3.3" -services: - usasapp: - networks: - - proxy - environment: - - APPLICATION_ADMIN_PASSWORD=test - - APPLICATION_ADMIN_RESET=true - - VIRTUAL_HOST=${COMPOSE_PROJECT_NAME}-usas.demo2.ssdt.io - - VIRTUAL_PORT=8080 - - LETSENCRYPT_HOST=${COMPOSE_PROJECT_NAME}-usas.demo2.ssdt.io - - LETSENCRYPT_EMAIL=smith@nwoca.org - - JAVA_OPTS=-Xmx840m - uspsapp: - networks: - - proxy - environment: - - APPLICATION_ADMIN_PASSWORD=test - - APPLICATION_ADMIN_RESET=true - - VIRTUAL_HOST=${COMPOSE_PROJECT_NAME}-usps.demo2.ssdt.io - - VIRTUAL_PORT=8080 - - LETSENCRYPT_HOST=${COMPOSE_PROJECT_NAME}-usps.demo2.ssdt.io - - LETSENCRYPT_EMAIL=smith@nwoca.org - - JAVA_OPTS=-Xmx840m -networks: - proxy: - external: - name: proxy_default -
--- a/pilot/setup.sh Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -#!/bin/bash -# Sets up a new district project based on SSDT default configuration in the current working directory. -# -# Usage: -# -# /data/preview/sampletown $ /ssdt/compose2/preview/setup.sh [usas,usps...] -# -# Will create a docker-compose.yml and .env file with default settings. -# -# -source "$(dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" - -md5calc() { - md5sum ${1} ; -} - -md5verify() { - md5sum -c --status ${1} ; -} - -genDBHash() { - echo $(date +%s%N | sha256sum | base64 | head -c 32 ; echo) -} - -base=$(dirname "${BASH_SOURCE[0]}") -default_name=$(basename $PWD) - -args="$1$2" - -usas="" -usps="" - -if [ "$args" == "" ] || [ -z "${args##*usas*}" ] -then - usas=1 -fi - -if [ "$args" == "" ] || [ -z "${args##*usps*}" ] -then - usps=1 -fi - -echo "Preparing '$(basename $PWD)' with default USxS configuration" - -touch .env -source .env - -if [ "$COMPOSE_PROJECT_NAME" == "" ] -then - read -e -p "Enter project name: <${default_name}> " answer - project_name=${answer:-$default_name} - echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env - echo "set project name in .env file" - source .env -fi - -if [ ! -e "docker-compose.yml" ] -then - create="OK" -elif [ -e ".docker-compose.md5" ]; then - md5verify ./.docker-compose.md5 && create="OK" -fi - -if [ "$create" == "OK" ] -then - echo "# **** DO NOT MODIFY THIS FILE. ****" > ./docker-compose.yml - echo "# Place customizations in docker-compose.override.yml and .env" >> ./docker-compose.yml - echo "version: \"3.3\"" >> ./docker-compose.yml - echo "services:" >> ./docker-compose.yml - - [ ! "$usas" == "" ] && cat $base/usas-services.yml >> ./docker-compose.yml - echo "" >> ./docker-compose.yml - - [ ! "$usps" == "" ] && cat $base/usps-services.yml >> ./docker-compose.yml - echo "" >> ./docker-compose.yml - - echo "volumes:" >> ./docker-compose.yml - - if [ ! "$usas" == "" ] - then - echo " usasdata:" >> ./docker-compose.yml - [ "$USAS_DB_PASSWORD" == "" ] && echo "USAS_DB_PASSWORD=$(genDBHash)" >> ./.env - fi - - if [ ! "$usps" == "" ] - then - echo " uspsdata:" >> ./docker-compose.yml - [ "$USPS_DB_PASSWORD" == "" ] && echo "USPS_DB_PASSWORD=$(genDBHash)" >> ./.env - fi - - echo "" >> ./docker-compose.yml - - md5calc ./docker-compose.yml > .docker-compose.md5 - - echo "created docker-compose.yml" - -else - echo " - - Error! docker-compose.yml file has been modified or checksum missing. Can not auto-apply update(s). - Move customizations to docker-compose.override.yml then delete the docker-compose.yml -" -fi - -if [ ! -e "docker-compose.override.yml" ] -then - echo 'version: "3.3"' >> docker-compose.override.yml -fi - -if [ "$USAS_APPLICATIONID" == "" ] -then - read -e -p "Generate USAS and USPS integration config? <Y/n> " answer - case $answer in - y | Y | yes | YES ) answer="y";; - n | N | no | NO ) answer="n";; - *) answer="y" - esac - if [ "$answer" == "y" ] - then - usas_id=${COMPOSE_PROJECT_NAME}-usas - usas_key=$(openssl rand -hex 32) - usps_id=${COMPOSE_PROJECT_NAME}-usps - usps_key=$(openssl rand -hex 32) - echo "USAS_APPLICATIONID=${usas_id}" >> .env - echo "USAS_APIKEY=$usas_key" >> .env - echo "USPS_APPLICATIONID=${usps_id}" >> .env - echo "USPS_APIKEY=$usps_key" >> .env - echo "Created integration API keys. Enable integration modules after applications start" - fi -fi - -if [ "$USAS_APP_HOST" == "" ] -then - echo "USAS_APP_HOST=usasapp-svr" >> .env -fi - -if [ "$USPS_APP_HOST" == "" ] -then - echo "USPS_APP_HOST=uspsapp-svr" >> .env -fi - -echo "Review or create a docker-compose.override.yml for custom settings." -
--- a/pilot/training.sh Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -#!/bin/bash -# Sets up a new Training project based on SSDT default configuration in the current working directory. -# -# Usage: -# -# /data/preview/training-01 $ /ssdt/compose2/preview/training.sh -# -# Will create a docker-compose.yml and .env file with default settings using the SSDT -# supplied training database -# -# These are special database images which recreates the database each time the container is created. -# Therefore, it is very easy to reset the training database simply by deleting the -# project containers and restarting them. for example: -# -# docker-compose down -# docker-compose up -d -# -source "$(dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" - -md5calc() { - md5sum ${1} ; -} - -md5verify() { - md5sum -c --status ${1} ; -} - -genDBHash() { - echo $(date +%s%N | sha256sum | base64 | head -c 32 ; echo) -} - -base=$(dirname "${BASH_SOURCE[0]}") -default_name=$(basename $PWD) - -args="$1$2" - -usas="" -usps="" - -if [ "$args" == "" ] || [ -z "${args##*usas*}" ] -then - usas=1 -fi - -if [ "$args" == "" ] || [ -z "${args##*usps*}" ] -then - usps=1 -fi - -echo "Preparing training project '$(basename $PWD)' with default USxS configuration" - -touch .env -source .env - -project_name=${default_name} - -if [ "$COMPOSE_PROJECT_NAME" == "" ] -then - echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env - source .env -fi - -if [ ! -e "docker-compose.yml" ] -then - create="OK" -elif [ -e ".docker-compose.md5" ]; then - md5verify ./.docker-compose.md5 && create="OK" -fi - -if [ "$create" == "OK" ] -then - - cat $base/training.yml > ./docker-compose.yml - echo "" >> ./docker-compose.yml - - md5calc ./docker-compose.yml > .docker-compose.md5 - - echo "created docker-compose.yml for training instance ${project_name}" - -else - echo " - - Error! docker-compose.yml file has been modified or checksum missing. Can not auto-apply update(s). - Move customizations to docker-compose.override.yml then delete the docker-compose.yml -" -fi - -if [ ! -e "docker-compose.override.yml" ] -then - echo 'version: "3.3"' >> docker-compose.override.yml -fi - -if [ "$USAS_APPLICATIONID" == "" ] -then - usas_id=${COMPOSE_PROJECT_NAME}-usas - usas_key=$(openssl rand -hex 32) - usps_id=${COMPOSE_PROJECT_NAME}-usps - usps_key=$(openssl rand -hex 32) - echo "USAS_APPLICATIONID=${usas_id}" >> .env - echo "USAS_APIKEY=$usas_key" >> .env - echo "USPS_APPLICATIONID=${usps_id}" >> .env - echo "USPS_APIKEY=$usps_key" >> .env - echo "Created integration API keys. Enable integration modules after applications start" -fi - -if [ "$USAS_APP_HOST" == "" ] -then - echo "USAS_APP_HOST=usasapp-svr" >> .env -fi - -if [ "$USPS_APP_HOST" == "" ] -then - echo "USPS_APP_HOST=uspsapp-svr" >> .env -fi - -echo "Review or create docker-compose.override.yml for custom settings." -
--- a/pilot/training.yml Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -# **** DO NOT MODIFY THIS FILE. ****" -# Place customizations in docker-compose.override.yml and .env -version: "3.3" -services: - usasdb: - restart: unless-stopped - image: docker.ssdt.io/trainingdb-usas:pilot - networks: - - default - environment: - - DB_NAME=usasdb - - DB_USER=usas - - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} - usasapp: - restart: unless-stopped - image: docker.ssdt.io/usas-app:${USAS_TAG:-pilot} - depends_on: - - usasdb - networks: - default: - aliases: - - ${USAS_APP_HOST:-usasapp-svr} - environment: - - APPLICATION_ADMIN_PASSWORD=training - - APPLICATION_ADMIN_RESET=true - - DB_HOST=usasdb - - DB_NAME=usasdb - - DB_USER=usas - - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} - - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTHOST=${USPS_APP_HOST:-uspsapp-svr} - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTDNSLOOKUP=true - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOST=0.0.0.0 - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOSTDNSLOOKUP=false - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APPLICATIONID=${USAS_APPLICATIONID:- } - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APIKEY=${USAS_APIKEY:- } - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPPLICATIONID=${USPS_APPLICATIONID:- } - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPIKEY=${USPS_APIKEY:- } - - JAVA_OPTS=-Xmx840m - uspsdb: - restart: unless-stopped - image: docker.ssdt.io/trainingdb-usps:pilot - networks: - - default - environment: - - DB_NAME=uspsdb - - DB_USER=usps - - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} - uspsapp: - restart: unless-stopped - image: docker.ssdt.io/usps-app:${USPS_TAG:-pilot} - depends_on: - - uspsdb - networks: - default: - aliases: - - ${USPS_APP_HOST:-uspsapp-svr} - environment: - - APPLICATION_ADMIN_PASSWORD=training - - APPLICATION_ADMIN_RESET=true - - DB_HOST=uspsdb - - DB_NAME=uspsdb - - DB_USER=usps - - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} - - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTHOST=${USAS_APP_HOST:-usasapp-svr} - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTDNSLOOKUP=true - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOST=0.0.0.0 - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOSTDNSLOOKUP=false - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APPLICATIONID=${USPS_APPLICATIONID:- } - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APIKEY=${USPS_APIKEY:- } - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPPLICATIONID=${USAS_APPLICATIONID:- } - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPIKEY=${USAS_APIKEY:- } - - JAVA_OPTS=-Xmx840m
--- a/pilot/usas-services.yml Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ - usasdb: - restart: unless-stopped - image: docker.ssdt.io/ssdt-postgres:5 - volumes: - - usasdata:/var/lib/postgresql/data - networks: - - default - environment: - - DB_NAME=usasdb - - DB_USER=usas - - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} - usasapp: - restart: unless-stopped - image: docker.ssdt.io/usas-app:${USAS_TAG:-pilot} - depends_on: - - usasdb - networks: - default: - aliases: - - ${USAS_APP_HOST:-usasapp-svr} - environment: - - DB_HOST=usasdb - - DB_NAME=usasdb - - DB_USER=usas - - DB_PASS=${USAS_DB_PASSWORD:-usasdefault} - - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTHOST=${USPS_APP_HOST:-uspsapp-svr} - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTDNSLOOKUP=true - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOST=0.0.0.0 - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOSTDNSLOOKUP=false - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APPLICATIONID=${USAS_APPLICATIONID:- } - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APIKEY=${USAS_APIKEY:- } - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPPLICATIONID=${USPS_APPLICATIONID:- } - - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPIKEY=${USPS_APIKEY:- }
--- a/pilot/usps-services.yml Thu Nov 15 20:10:48 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ - uspsdb: - restart: unless-stopped - image: docker.ssdt.io/ssdt-postgres:5 - volumes: - - uspsdata:/var/lib/postgresql/data - networks: - - default - environment: - - DB_NAME=uspsdb - - DB_USER=usps - - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} - uspsapp: - restart: unless-stopped - image: docker.ssdt.io/usps-app:${USPS_TAG:-pilot} - depends_on: - - uspsdb - networks: - default: - aliases: - - ${USPS_APP_HOST:-uspsapp-svr} - environment: - - DB_HOST=uspsdb - - DB_NAME=uspsdb - - DB_USER=usps - - DB_PASS=${USPS_DB_PASSWORD:-uspsdefault} - - DB_POOL_LEAKDETECTIONTHRESHOLD=300000 - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTHOST=${USAS_APP_HOST:-usasapp-svr} - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTDNSLOOKUP=true - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOST=0.0.0.0 - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_SERVERHOSTDNSLOOKUP=false - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APPLICATIONID=${USPS_APPLICATIONID:- } - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APIKEY=${USPS_APIKEY:- } - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPPLICATIONID=${USAS_APPLICATIONID:- } - - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPIKEY=${USAS_APIKEY:- }
--- a/postgres/Dockerfile Thu Nov 15 20:10:48 2018 +0000 +++ b/postgres/Dockerfile Thu Dec 27 00:06:14 2018 +0000 @@ -1,7 +1,7 @@ # # Docker file to create postgres image for ssdt applications -FROM postgres:9.6.3 +FROM postgres:9.6.11 MAINTAINER Dave Smith smith@nwoca.org
--- a/scripts/backup-container.sh Thu Nov 15 20:10:48 2018 +0000 +++ b/scripts/backup-container.sh Thu Dec 27 00:06:14 2018 +0000 @@ -15,14 +15,16 @@ source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh" +project=$(composeGetProject) + set -o pipefail mkdir -p ./backup -backupFile=./backup/${container}.$(date +%Y-%m-%d-%H-%M-%S).backup +backupFile=./backup/${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup echo "preparing to backup ${container} on current project at ${projectDir}:" echo " " -project=$(composeGetProject) + if [ "$project" == "" ]; then echo "no project available"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/remote-backup-all.sh Thu Dec 27 00:06:14 2018 +0000 @@ -0,0 +1,97 @@ +#!/bin/bash +# Executes a database backup for the specified database container. +# The current directory is expected to contain a project configured +# as with SSDT conventions for an application database. +# +# When successful, the output file will be in ./backup with the +# container name and timestamp in the file. +# The file will also be placed on the specified remote target +# The format of the output is a compressed pg_dump (sql) format. +# +# +# This will backup both usasdb and uspsdb, +# along with the top level contents of the project directory +#Environment variables can be used for REMOTE_BACKUP_TARGET and REMOTE_USERNAME + +remoteTarget=${1:-$REMOTE_BACKUP_TARGET} +userName=${2:-$REMOTE_USERNAME} +projectDir=${3:-$PWD} + + +cd $projectDir + +source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh" + +set -o pipefail +mkdir -p ./backup + +container1=usasdb +container2=uspsdb + +project=$(composeGetProject) + +echo "project is $project" +echo "Containers are $container1 and $container2" +echo "Remote target is $remoteTarget" +echo "Username is $userName" + +if [ "$project" == "" ]; then + echo "no project available" + exit 1 +fi + + +backupFile1=./backup/${project}-${container1}.$(date +%Y-%m-%d-%H-%M-%S).backup +backupFile2=./backup/${project}-${container2}.$(date +%Y-%m-%d-%H-%M-%S).backup +backupFile3=./backup/${project}-directory.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz + +#usasdb +echo "starting backup of $container1 for $project" +docker-compose exec -T $container1 sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container1 ; (exit $?) " > ${backupFile1} + + 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 + gzip ${backupFile1} + + echo "completed backup of $container1 for $project to ${backupFile1}" + + fi + + +##### +#uspsdb is being used + +echo "starting backup of $container2 for $project" +docker-compose exec -T $container2 sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container2 ; (exit $?) " > ${backupFile2} + + 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 + gzip ${backupFile2} + + echo "completed backup of $container2 for $project to ${backupFile2}" + + fi + +####### + +#backup of all files in current directory +echo "starting backup of current directory for $project" + +tar -czf ${backupFile3} . --exclude=./backup + +echo "completed backup of all files for $project to ${backupFile3}" + + +# +# +scp ${backupFile1}.gz ${backupFile2}.gz ${backupFile3} $userName@$remoteTarget + +echo " " + +echo "completed sending ${backupFile1}.gz, ${backupFile2}.gz, and ${backupFile3} to ${remoteTarget} as user $userName" + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/remote-backup.sh Thu Dec 27 00:06:14 2018 +0000 @@ -0,0 +1,71 @@ +#!/bin/bash +# Executes a database backup for the specified database container. +# The current directory is expected to contain a project configured +# as with SSDT conventions for an application database. +# +# When successful, the output file will be in ./backup with the +# container name and timestamp in the file. +# The file will also be placed on the specified remote target +# The format of the output is a compressed pg_dump (sql) format. +# along with the top level contents of the project directory +# Environment variables can be used for REMOTE_BACKUP_TARGET and REMOTE_USERNAME +# + + +container=${1?Must provide container name to backup} +remoteTarget=${2:-$REMOTE_BACKUP_TARGET} +userName=${3:-$REMOTE_USERNAME} +projectDir=${4:-$PWD} + + +cd $projectDir + +source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh" + +set -o pipefail +mkdir -p ./backup + +project=$(composeGetProject) + +echo "Project is $project" +echo "Container is $container" +echo "Remote target is $remoteTarget" +echo "Username is $userName" + +backupFile=./backup/${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup +backupFile2=./backup/${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz + + +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} + +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: $(tail ${backupFile})" + exit 1 +fi + +gzip ${backupFile} + +echo "completed backup of $container for $project to ${backupFile}" + +#backup of all files in current directory +tar -czf ${backupFile2} . --exclude=./backup + +echo "completed backup of all files for $project to ${backupFile2}" + + +# +# +scp ${backupFile}.gz ${backupFile2} $userName@$remoteTarget + +echo " " + +echo "completed sending ${backupFile}.gz and ${backupFile2} to ${remoteTarget} as user $userName" + +