Strapi
Load DB for local development

Load Production or Staging database dump in local development

You'll need access to our Azure Devops project (opens in a new tab) to access the database dumps.

Using @bratislava/ristor

See the repository (opens in a new tab).

Manually

You can then use the db-backup pipeline (opens in a new tab) to browse recent backups on different k8s deployed projects. Each run produces an artifact in which you'll find the db dump.

In all likelihood, you'll be interested in the runs titled <Env>_standalone, where <Env> is the k8s cluster you are after.

Assuming you have:

  • postgres server running locally & psql cli tool installed
  • a user/role called strapi
  • a database your_strapi_db

you can load the dump newest-db-dump.sql like so:

psql -h localhost -p 5432 -U strapi your_strapi_db < newest-db-dump.sql

It's not always necessary, but recommended, to have a role called strapi on your local Postgres server when doing this with a Strapi db dump - as the tables may reference role with this name directly. Alternative might be editing the dump and renaming the role referenced to one you have available locally.

Docker DB

Commands needed to seed postgres on docker container. Please replace your_strapi_db with the strapi db name.

  1. Copy dump: docker cp strapi-backup.sql your_strapi_db-postgres-1:/strapi-backup.sql
  2. Seed db: docker exec your_strapi_db-postgres-1 sh -c "psql -U strapi strapi < strapi-backup.sql"

To login into the db dumped this way, you may need to ask for access from the project lead.

See Sync Strapi database to different environment for guide on dumping live database directly from the server, instead of relying on the regular db dumps in pipeline.

Note about possible error

When seeding the database dump, if you encounter ERROR: constraint ... already exists, this is possibly a sign of incorrectly loaded data. To fix this, delete the schema public and then create a new empty one. Then immediately seed the db again, before running strapi.