Mercurial > public > ssdt-docker
view scripts/restore-workflow.sh @ 591:9f77e0438846 production
Added tag v2.20.0 for changeset 80f3564f2553
author | Marc Davis <marc.davis@mcoecn.org> |
---|---|
date | Thu, 05 Sep 2024 15:01:40 -0400 |
parents | 639c933cefee |
children |
line wrap: on
line source
#!/bin/bash source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh" sourceFile=${1?must provide backup file to be restored} if [ -z "$1" ] then echo "Usage: `basename $0` {backup file to restore}" echo " must specify the name of the file to restore. Assumed to be in format:" echo " {entityId}-workflows-db.{timestamp}.backup.gz " exit $E_NOARGS fi function prop { grep "${1}" .env/ssdt-workflows-shared.properties|cut -d'=' -f2 } entityId=$(prop 'entityId' | tr -d '"') dbContainerName="$entityId-workflows-db" appContainerName="$entityId-workflows-app" target="workflowsdb" echo echo "Preparing to restore" echo "--------------------" echo " file: $sourceFile" echo " to $dbContainerName database: $target" echo " " echo "WARNING: This operation will DELETE and replace any exising database" echo " " read -e -p "Continue? <y/N> " answer case $answer in y | Y | yes | YES ) answer="y";; n | N | no | NO ) answer="n";; *) answer="n" esac if [ "$answer" == "y" ] then echo "stopping application service $appContainerName" docker stop $appContainerName echo "copy backup file to database container" docker cp ${sourceFile} ${dbContainerName}:/tmp/restore.backup.gz echo "starting database restore" docker exec -t -u postgres $dbContainerName sh -c "gunzip -f /tmp/restore.backup.gz -c | psql" fi