Mercurial > public > ssdt-docker
comparison scripts/.functions.sh @ 73:d2c44193fbaa
explictly remove db's before import
author | smith@nwoca.org |
---|---|
date | Mon, 21 Mar 2016 22:17:55 +0100 |
parents | scripts/info.sh@1988f9924439 |
children | 85957628f4c0 |
comparison
equal
deleted
inserted
replaced
72:6f562946db80 | 73:d2c44193fbaa |
---|---|
1 #!/bin/bash | |
2 | |
3 # deletes psql data from specified service | |
4 resetDbVolume() { | |
5 # Works for named and unnamed volumes and custom $PGDATA. | |
6 # Container must be stopped | |
7 service=${1?Must supply db service to reset} | |
8 container=$(composeGetContainer $service) | |
9 if [ "$container" != "" ] | |
10 then | |
11 echo "deleting db data from $container" | |
12 docker-compose run --no-deps --rm $service bash -c "rm -rf \${PGDATA?Missing PGDATA env}" | |
13 fi | |
14 } | |
15 | |
16 # finds docker container for specified compose service | |
17 composeGetContainer() { | |
18 service=${1?"Must supply service from current project"} | |
19 | |
20 container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ ) | |
21 echo $container | |
22 } |