Skip to content

Commit

Permalink
fix restore db dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ychab committed Jun 17, 2024
1 parent 9dfe313 commit be15ef6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,18 @@ restore_media:
rm -Rf media_old latest.tar.gz

restore_db:
# First drop the DB
docker compose down --volumes
# Then recreate the DB (and wait for it's ready!)
FOLIOBLOG_HEALTHCHECK_INTERVAL=5s FOLIOBLOG_HEALTHCHECK_RETRIES=10 docker compose up --detach --wait
# Then fetch remote backup and restore it.
# first fetch remote backup file.
scp ${FOLIOBLOG_BACKUP_HOST}:${FOLIOBLOG_BACKUP_PATH_SQL}/*.sql.gz ./dump.sql.gz
# Then stop any services and drop the DBs (postgres + redis)
docker compose down --volumes
# Then recreate the DB only (and wait for it's ready!)
docker compose up --detach --wait postgres
# Import the DUMP
gunzip < dump.sql.gz | docker compose exec --no-TTY postgres psql --quiet -U ${FOLIOBLOG_POSTGRES_USER} -d ${FOLIOBLOG_POSTGRES_DB}
# Finally cleanup the room!
# Cleanup the room!
rm -f dump.sql.gz
# Finally restart all services
docker compose up --detach --wait

restore_local: restore_media restore_db
python manage.py createadmin --password=admin
Expand Down
2 changes: 2 additions & 0 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ deploy_dev() {

echo -e "\n-> Restore DB and media\n"
make restore_dev
make appmigrate
else
echo -e "\n-> Restore initial data\n"
make initial_data_dev
Expand Down Expand Up @@ -191,6 +192,7 @@ deploy_prod() {

echo -e "\n-> Restore DB and media\n"
make restore_prod
make appmigrate
else
echo -e "\n-> Restore initial data\n"
make appmigrate
Expand Down

0 comments on commit be15ef6

Please sign in to comment.