mirror of https://github.com/ekimekim/wubloader
script to read in dumps
parent
1a7d3e6ff1
commit
413c86d908
@ -0,0 +1,25 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
if [ -z $1 ]
|
||||||
|
then
|
||||||
|
echo "No SQL script file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
NAME=${2:-postgres}
|
||||||
|
CONTAINER=$(docker ps --format "{{.Names}}" | grep "$NAME")
|
||||||
|
if [ -z "$CONTAINER" ]
|
||||||
|
then
|
||||||
|
echo "Container not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#need to do this in case db dump file has a colon in it
|
||||||
|
cp $1 tmp.sql
|
||||||
|
docker cp tmp.sql "$CONTAINER:/"
|
||||||
|
rm tmp.sql
|
||||||
|
|
||||||
|
docker exec $CONTAINER dropdb wubloader -U postgres
|
||||||
|
docker exec $CONTAINER createdb wubloader -U postgres
|
||||||
|
docker exec $CONTAINER psql -d wubloader -f dump.sql -U postgres
|
||||||
|
docker exec $CONTAINER rm tmp.sql
|
Loading…
Reference in New Issue