contratospr-api icon indicating copy to clipboard operation
contratospr-api copied to clipboard

Get a current database dump

Open froi opened this issue 4 years ago • 3 comments

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?

froi avatar Aug 13 '20 14:08 froi

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

jpadilla avatar Aug 13 '20 15:08 jpadilla

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!

froi avatar Aug 13 '20 15:08 froi

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

github-actions[bot] avatar Sep 13 '20 00:09 github-actions[bot]