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

Get a current database dump #152

Open
froi opened this issue Aug 13, 2020 · 3 comments
Open

Get a current database dump #152

froi opened this issue Aug 13, 2020 · 3 comments

Comments

@froi
Copy link
Member

froi commented Aug 13, 2020

I've been asked for a dump of our database with our most current data. The purpose is to use this dump for some data analysis.

@jpadilla any thoughts on how best to fulfill this request?

@jpadilla
Copy link
Contributor

I recommend doing something like this:

pg_dump -v -Fc --no-acl --no-owner \
  -h <HOST> \
  -U <USERNAME> \
  --table=contracts_contract \
  --table=contracts_contract_contractors \
  --table=contracts_contractor \
  --table=contracts_document \
  --table=contracts_entity \
  --table=contracts_service \
  --table=contracts_servicegroup \
  <DATABASE> > contratospr-api-2020-08-13.dump

Note: This will exclude any session, user, and django-specific tables.

Get details from DATABASE_URL in heroku config -a contratospr-api. You'll need to make sure it can be imported back, with a local postgres database running:

pg_restore --verbose --clean --no-acl --no-owner \
  -h localhost \
  -U myuser \
  -d mydb \
  contratospr-api-2020-08-13.dump

Ideally afterwards that's confirmed, use the AWS credentials(from heroku config as well) to upload to S3:

aws s3 cp ./contratospr-api-2020-08-13.dump s3://data.contratospr.com/2020-08-13/ --acl public-read

@froi
Copy link
Member Author

froi commented Aug 13, 2020

Ideally afterwards that's confirmed, use the AWS credentials(from heroku config as well) to upload to S3:

This was what I was really wondering about

I'll work on it later today. Thanks!

@github-actions
Copy link

This Issue is being marked as Stale because it has 30 days without any interaction. CC: @froi @jpadilla

@froi froi assigned froi and unassigned froi Dec 7, 2020
@froi froi closed this as completed Dec 7, 2020
@froi froi reopened this Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants