Skip to content

Create staging database

Kuan Fan edited this page Jun 4, 2018 · 11 revisions

On Prod

Backup prod database

  • Login prod postgresql pod and run command "pg_dump tfrs | gzip > /postgresql-backup/SQLDump/prod/tfrs-[DateTime].gz"
  • Copy the above database dump to local drive "oc rsync [pod name]:[path to the dump file] [local drive]"

On Test

Create the secret for staging database on test

  • Create secret tfrs-postgresql-staging which contains same content as prod secret tfrs-postgresql

Create storage

  • Create postgresql-staging-cns storage

Bring down the postgresql database

Create DC/postgresql-staging

  • Create DC/postgresql-staging and mountpostgresql-backup-cns to it
  • Use the secret tfrs-postgresql-staging for environment variable

Copy the prod SQL Dump file to staging

  • oc rsync [local drive] [pod name]:[path to the dump file]

Run following command to restore staging database from prod dump file

  • psql tfrs
  • #DROP SCHEMA public CASCADE;
  • #CREATE SCHEMA public;
  • #GRANT ALL ON SCHEMA public TO postgres;
  • #GRANT ALL ON SCHEMA public TO public;
  • quit psql
  • run command 'gunzip -c /postgresql-backup/SQLDump/tfrs-[DateTime].gz | psql tfrs'

Update the selector of postgresql service to choose postgresql-staging