Skip to content

Commit

Permalink
Merge pull request #41 from jandd/improve-prod-backup
Browse files Browse the repository at this point in the history
Improve prod backup
  • Loading branch information
jandd committed Oct 8, 2018
2 parents a1649f8 + 172dc27 commit 046bcda
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ fi

case "$cmd" in
backup)
$DOCKER_COMPOSE up -d
echo "*** Running backup"
# sleep a few seconds to wait for the database to finish start
sleep 5
$DOCKER_COMPOSE up -d db
$DOCKER_COMPOSE exec db sh -c 'while ! pg_isready; do sleep 1; done'
BACKUPDATA=$(date +%Y%m%d-%H%M%S%z)
mkdir -p backup
$DOCKER_COMPOSE exec db pg_dump -U postgres devday | gzip > "backup/prod-db-${BACKUPDATA}.sql.gz"
$DOCKER_COMPOSE exec -T app tar cz -C /srv/devday/media . > "backup/prod-media-${BACKUPDATA}.tar.gz"
$DOCKER_COMPOSE run --rm --no-deps -T app tar cz -C /srv/devday/media . > "backup/prod-media-${BACKUPDATA}.tar.gz"
;;
build)
# Relevant for production/test environments with full vault setup
Expand Down

0 comments on commit 046bcda

Please sign in to comment.