External Database (Postgres)

Our database service, Postgres, comes installed, by default, with OpenReplay and runs in a dedicated container on your instance for a lower cost of deployment. If you’re looking for greater scalability or easier operations, you can still use an external Postgres (i.e. AWS RDS or GCP Cloud SQL).

Update your Postgres variables

Section titled Update your Postgres variables

The very first step is to update all postgres variables in openreplay/scripts/helmcharts/vars.yaml and point them towards the external database:

  postgresqlPassword: "changeMePassword"
  postgresqlHost: "postgresql.db.svc.cluster.local"
  postgresqlPort: "5432"
  postgresqlUser: "postgres"
  postgresqlDatabase: "postgres"

Export existing schema and data

Section titled Export existing schema and data

Note: If you’re starting fresh and haven’t yet installed OpenReplay, then simply proceed with the setup and ignore the following steps.

The local schema and recorded data must now be exported to the external Postgres:

  1. First, backup the local database:
kubectl exec -n db postgresql-postgresql-0 -- bash -c 'PGPASSWORD=<postgresPassword from vars.yaml> pg_dumpall -U postgres '"  > ~/path/to/dump.sql
  1. Install the Postgres client on your OpenReplay instance and ensure it has access to the external database:
sudo apt install postgresql-client
  1. Restore the backup into the new externalPostgres:
PGPASSWORD=PG_PASSWORD psql -U PG_USERNAME -h [RDS_URL} -d postgres < /path/to/dump.sql
  1. Finally, restart all OpenReplay services:
cd openreplay/scripts/helmcharts && ./openreplay-cli -I

If you encounter any issues, please connect to our Slack and get help from our community.