Skip to content

Commit

Permalink
Merge pull request #237 from platanus/restore-db
Browse files Browse the repository at this point in the history
feat(makefile): add restore-from commands for pg_restore
  • Loading branch information
imarquezc authored Jan 21, 2020
2 parents d4253f1 + 60675f7 commit 6085fd4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/potassium/assets/Makefile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,18 @@ services-logs:
services-port:
@set -o pipefail; \
docker-compose $(DOCKER_COMPOSE_ARGS) port ${SERVICE} ${PORT} 2> /dev/null | cut -d':' -f2 || echo ${PORT}

backup-staging: ROLE=staging
backup-production: ROLE=production
backup-%:
@echo Capturing $(ROLE)....
@heroku pg:backups:capture --remote $(ROLE)

restore-from-staging: ROLE=staging
restore-from-production: ROLE=production
restore-from-%:
$(eval TEMP_FILE=$(shell mktemp))
@echo Restoring from $(ROLE)....
@heroku pg:backups:download --remote $(ROLE) --output $(TEMP_FILE)
@pg_restore --verbose --clean --no-acl --no-owner -h localhost \
-U postgres -p $(shell make services-port SERVICE=postgresql PORT=5432) -d $(PROJECT)_development $(TEMP_FILE)

0 comments on commit 6085fd4

Please sign in to comment.