Youtube GitHub LinkedIn Email
sign in
Learn cloud developer skills Deploy apps to OpenShift Local Switch to Linux SPINE Programming Theory
solutions
Developer Computer Management Smart Agriculture Developers Smart Aquaculture Developers AI Telemetry developers Computate Developers
about use cases courses articles events webinars services research websites

How to backup and restore the computate.org database

by Christopher Tate

Connect to your OpenShift cluster running the database that needs to be backed up.

Make a directory on the pod for the backup

oc -n postgres exec $(oc -n postgres get pod -l postgres-operator.crunchydata.com/role=master -o name) -- \
  mkdir -p /pgdata/backup/

Back up the database

oc -n postgres exec $(oc -n postgres get pod -l postgres-operator.crunchydata.com/role=master -o name) -- \
  bash -c "pg_dump -U computateorg computateorglocal > /pgdata/backup/computateorglocal.sql"

Make a directory on your own computer for the database backup

mkdir -p ~/Downloads/backup/

Rsync the backup file to your computer

oc -n postgres rsync $(oc -n postgres get pod -l postgres-operator.crunchydata.com/role=master -o name):/pgdata/backup/ ~/Downloads/backup/

Connect to your OpenShift cluster running Postgres where you would like to restore the database.

Make a directory on the pod for the backup

oc -n postgres exec $(oc -n postgres get pod -l postgres-operator.crunchydata.com/role=master -o name) -- \
  mkdir -p /pgdata/restore/

Rsync the backup file to your Postgres pod

oc -n postgres rsync ~/Downloads/backup/ $(oc -n postgres get pod -l postgres-operator.crunchydata.com/role=master -o name):/pgdata/restore/

Drop the public schema and recreate a new public schema

oc -n postgres exec $(oc -n postgres get pod -l postgres-operator.crunchydata.com/role=master -o name) -- \
  bash -c "psql -U computateorg computateorglocal -c 'drop schema public cascade; create schema public; '"

Restore the database

oc -n postgres exec $(oc -n postgres get pod -l postgres-operator.crunchydata.com/role=master -o name) -- \
  bash -c "psql -U computateorg computateorglocal < /pgdata/restore/computateorglocal.sql"

Don't forget to share this page!

LinkedIn
Facebook
This site is open source
Generated with Computate
Powered by Google Kubernetes Engine

Crack the code on writing code

Computate.org is an open source software company providing advanced tools for building data-driven websites with OpenAPIs and fine-grained authorization standards, for the last 20 years.

Project

Java backend Frontend content

Special Thanks

Font Awesome Web Awesome paul-hammant/qdox
Privacy Policy Terms of Service

© Computate Limited Liability Company in Utah, USA.