Skip to content

Loading deployed data locally

Dan Guy edited this page Jul 30, 2025 · 2 revisions

When debugging issues that arise on Dev, Stage, and Test, we may need to pull down the data from the database to debug locally. One way of achieving this is to psql dump the database and load it in docker.

  1. Authenticate. cf login -a api.fr.cloud.gov --sso
  2. Connect to database and dump a copy
  3. Prepare .sql file
    • Because the connect plugin sets the owner to the user that did the pull, we'll run into problems when running the .sql because that user wont exist.
    • Replace all instances of that username with postgres, i.e. sed -i 's/<"Username">/postgres/g' <dump file>.sql
      • NOTE: look into --no-owner flag for pg_dump to avoid this issue
    • Move your dump file into fecfile-web-api/db/
  4. Load into docker
    • Add COPY <space>_dump_<date>.sql /docker-entrypoint-initdb.d/1.sql to db/Dockerfile
    • Run docker compose down then docker compose build --no-cache. Both are important. Running just one or the other will prevent the db from loading how you want it to.
    • Make the test user the committee administrator of the committee you want to troubleshoot by adding the following to django-backend/fixtures/e2e-test-data.json:
...},
{
    "model": "committee_accounts.Membership",
    "pk": "abcd1234-06c1-42b7-a379-274d84535526",
    "fields": {
        "role": "COMMITTEE_ADMINISTRATOR",
        "committee_account_id": "<uuid of committee account>",
        "user_id": "e100e1da-cbfc-4189-aece-d139048a8e0a",
        "pending_email": null,
        "created": "2022-02-09T00:00:00.000Z",
        "updated": "2022-02-09T00:00:00.000Z"
    }
}

Run docker compose up and your data should be available

Clone this wiki locally