Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to sync with DB on prod #759

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ install: conda
# pip install git+https://github.com/mskcc/beagle_cli.git@develop
# pip install -r requirements-cli.txt # <- what happened to this file?

BEAGLE_BACKUP_DB_FOLDER=/juno/work/ci/beagle_backups/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this just makes it more complicated than necessary but this could maybe be an env var


export ENVIRONMENT=dev
# ~~~~~ Set Up Demo Postgres Database for Dev ~~~~~ #
export BEAGLE_DB_NAME=db
Expand Down Expand Up @@ -172,13 +174,18 @@ db-backup: $(DB_BACKUP_DIR)
db-restore:
@echo ">>> restoring db from DBFILE: $(DBFILE)"
if [ -n "$(DBFILE)" ]; then \
psql "$(PGDATABASE)" < "$(DBFILE)" ; fi
pg_restore -h $(PGHOST) -p $(PGPORT) --no-privileges --no-owner --clean -d $(PGDATABASE) < "$(DBFILE)" ; fi

# interactive Postgres console
# use command `\dt` to show all tables
db-inter:
psql -p "$(PGPORT)" -U "$(PGUSER)" -W "$(PGDATABASE)"

db-sync-prod:
LATEST_DUMP=`ssh voyager ls -Art $(BEAGLE_BACKUP_DB_FOLDER) | tail -n 1` && \
rsync --progress voyager:$(BEAGLE_BACKUP_DB_FOLDER)$$LATEST_DUMP . && \
pg_restore -d $(PGDATABASE) < $$LATEST_DUMP


# ~~~~~~ Celery tasks & RabbitMQ setup ~~~~~ #
# !! need to start RabbitMQ before celery, and both before running Django app servers !!
Expand Down