Skip to content

Commit 5a33897

Browse files
committed
Add retore command
1 parent baeecd7 commit 5a33897

6 files changed

Lines changed: 36 additions & 4 deletions

File tree

.env.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FLOWER_PORT=${FLOWER_PORT}
44
FLOWER_PASSWORD=${FLOWER_PASSWORD}
55
HOST_POSTGRES_DUMP=${HOST_POSTGRES_DUMP}
66
MAPBOX_API_KEY=${MAPBOX_API_KEY}
7+
POSTGRES_DUMP_HOST=${POSTGRES_DUMP_HOST}
8+
POSTGRES_DUMP_CONTAINER=${POSTGRES_DUMP_CONTAINER}
79
POSTGRES_HOST=${POSTGRES_HOST}
810
POSTGRES_PORT=${POSTGRES_PORT}
911
POSTGRES_USER=${POSTGRES_USER}

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
ENV: dev
1111
FLOWER_PORT: 28888
1212
FLOWER_PASSWORD: flowerpass
13-
HOST_POSTGRES_DUMP: /tmp/dump
13+
POSTGRES_DUMP_HOST: /tmp/dump
1414
POSTGRES_HOST: epigraphhub-db
1515
POSTGRES_PORT: 25432
1616
POSTGRES_USER: postgres

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SERVICE:=epigraphhub-superset
44
ENV:=dev
55
CONSOLE:=bash
66
CRON:=
7+
FILE:=
78

89
DOCKER=docker-compose \
910
--env-file .env \
@@ -108,6 +109,16 @@ docker-run-bash:
108109
$(DOCKER) run --rm ${SERVICE} bash
109110

110111

112+
.PHONY:docker-db-dump
113+
docker-db-dump:
114+
$(DOCKER) exec -T epigraphhub-superset bash \
115+
/opt/EpiGraphHub/docker/postgresql/dump.sh
116+
117+
.PHONY:docker-db-restore
118+
docker-db-restore:
119+
$(DOCKER) exec -T epigraphhub-superset bash \
120+
/opt/EpiGraphHub/docker/postgresql/restore.sh ${FILE}
121+
111122
# ANSIBLE
112123

113124
.PHONY:deploy

docker/compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ services:
3838
volumes:
3939
- ..:/opt/EpiGraphHub
4040
- ${SUPERSET_DB_PATH_DIR_HOST}:/opt/data/superset/
41+
- ${POSTGRES_DUMP_HOST}:${POSTGRES_DUMP_CONTAINER}
4142
ports:
4243
- ${SUPERSET_PORT}:8088
4344
depends_on:

docker/postgresql/dump.sh

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ if [ -f ${PROJECT_DIR}/.env ]; then
77
export $(cat ${PROJECT_DIR}/.env | grep -v '#' | sed 's/\r$//' | awk '/=/ {print $1}' )
88
fi
99

10-
HOST_POSTGRES_DUMP=${HOST_POSTGRES_DUMP:-/tmp/dump}
11-
mkdir -p ${HOST_POSTGRES_DUMP}
10+
POSTGRES_DUMP_HOST=${POSTGRES_DUMP_HOST:-/tmp/dump}
11+
mkdir -p ${POSTGRES_DUMP_HOST}
1212

1313
set -ex
1414

1515
PGPASSWORD=${POSTGRES_PASSWORD} pg_dumpall \
1616
--host ${POSTGRES_HOST} \
1717
--port ${POSTGRES_PORT} \
1818
--user ${POSTGRES_USER} \
19-
> ${HOST_POSTGRES_DUMP}/$(date --iso-8601).dump
19+
> ${POSTGRES_DUMP_HOST}/$(date --iso-8601).dump

docker/postgresql/restore.sh

100644100755
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd ../.. && pwd )"
4+
5+
if [ -f ${PROJECT_DIR}/.env ]; then
6+
# Load Environment Variables
7+
export $(cat ${PROJECT_DIR}/.env | grep -v '#' | sed 's/\r$//' | awk '/=/ {print $1}' )
8+
fi
9+
10+
POSTGRES_DUMP_HOST=${POSTGRES_DUMP_HOST:-/tmp/dump}
11+
12+
set -ex
13+
14+
PGPASSWORD=${POSTGRES_PASSWORD} psql \
15+
--host ${POSTGRES_HOST} \
16+
--port ${POSTGRES_PORT} \
17+
--user ${POSTGRES_USER} \
18+
-f ${POSTGRES_DUMP_HOST}/${1} ${POSTGRES_DB}

0 commit comments

Comments
 (0)