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