mirror of https://github.com/ekimekim/wubloader
fixes in response to ekim's comments
parent
1dbe585837
commit
027c2900e2
@ -1,13 +1,16 @@
|
||||
#! /bin/bash
|
||||
NAME=${1:-postgres}
|
||||
BUCKET=${2:-wubloader-db}
|
||||
CONTAINER=$(docker ps --format "{{.Names}}" | grep "$NAME")
|
||||
if [ -z "$CONTAINER" ]
|
||||
then
|
||||
if [ -z "$CONTAINER" ]; then
|
||||
echo "Container not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(wc -l <<<"$CONTAINER")" -ne 1 ]; then
|
||||
echo "Multiple containers found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILE="wubloader-$(date +%Y-%m-%dT%H:%M:%S).sql"
|
||||
echo "Dumping $CONTAINER to $FILE"
|
||||
docker exec $CONTAINER pg_dump wubloader -U postgres > $FILE
|
||||
aws s3 cp $FILE s3://wubloader-test
|
||||
rm $FILE
|
||||
docker exec $CONTAINER pg_dump wubloader -U postgres | aws s3 cp - "s3://$BUCKET/$FILE"
|
||||
|
@ -1,25 +1,31 @@
|
||||
#! /bin/bash
|
||||
|
||||
if [ -z $1 ]
|
||||
then
|
||||
if [ -z "$1" ]; then
|
||||
echo "No SQL script file"
|
||||
echo "USAGE: $0 SQL_SCRIPT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NAME=${2:-postgres}
|
||||
CONTAINER=$(docker ps --format "{{.Names}}" | grep "$NAME")
|
||||
if [ -z "$CONTAINER" ]
|
||||
then
|
||||
if [ -z "$CONTAINER" ]; then
|
||||
echo "Container not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(wc -l <<<"$CONTAINER")" -ne 1 ]; then
|
||||
echo "Multiple containers found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#need to do this in case db dump file has a colon in it
|
||||
cp $1 tmp.sql
|
||||
cp "$1" tmp.sql
|
||||
docker cp tmp.sql "$CONTAINER:/"
|
||||
rm tmp.sql
|
||||
|
||||
docker exec $CONTAINER dropdb wubloader -U postgres --if-exists
|
||||
docker exec $CONTAINER createdb wubloader -U postgres
|
||||
docker exec $CONTAINER psql -d wubloader -f dump.sql -U postgres
|
||||
docker exec $CONTAINER rm tmp.sql
|
||||
# this will fail if there are active sessions by users other than 'postgres'
|
||||
# make sure all wubloader components are disconnected
|
||||
docker exec "$CONTAINER" dropdb wubloader -U postgres --if-exists
|
||||
docker exec "$CONTAINER" createdb wubloader -U postgres
|
||||
# this assumes that the vst role is in the postgres database
|
||||
docker exec "$CONTAINER" psql -d wubloader -f tmp.sql -U postgres
|
||||
docker exec "$CONTAINER" rm tmp.sql
|
||||
|
@ -1,5 +1,5 @@
|
||||
FROM postgres:latest
|
||||
COPY postgres/setup.sh /docker-entrypoint-initdb.d/setup.sh
|
||||
COPY postgres/standby_setup.sh /standby_setup.sh
|
||||
RUN chmod 0666 /docker-entrypoint-initdb.d/setup.sh
|
||||
COPY postgres/standby_setup.sh /standby_setup.sh
|
||||
RUN chmod 0700 /standby_setup.sh
|
||||
|
Loading…
Reference in New Issue