Skip to content

Restore a database backup (manual)

Steve Hillier edited this page Jun 6, 2019 · 1 revision

Database backups are created using the backup container and stored in 3 places:

  • in the database pod (pre-deploy backup)
  • in the cluster on a backup PVC (nightly)
  • in the BCGov NFS storage (nightly)

The backups can be restored manually as follows:

  1. Mount the backup PVC to a running database pod.
  • If no database is available or you want to test this process without affecting the app's database, you may use oc new-app to start a new temporary database (TODO: more instructions. Until then, check oc-new app documentation). The database currently uses the postgresql-9.6-oracle-fdw image.
  • Use the OpenShift GUI to navigate to a database deployment and select "add storage".
  • Choose a mount point (such as /backup) and check read only.
  • Depending on the environment, there will be several gwells-psql-backup and/or bk-gwells-nfs PVCs with backups.
  • Use the terminal to browse available backups on the PVC after mounting and waiting for the pods to come back up.
  1. Unzip and edit the backup file.
  • Copy the backup to /tmp and use gunzip my_db_backup.sql.gz
  • We haven't yet automated the restore process. Current backups require some manual steps:
    • use a text editor (the environments have vi installed) and comment out the line CREATE USER MAPPING ... (search for it)
    • add CREATE ROLE fdw_reader;
  1. Restore the backup
  • psql -d gwells -x -v ON_ERROR_STOP=1 < my_db_backup.sql
  1. You may need to re-run any migrations that have occurred since the backup was taken. You can re-deploy the GWELLS deployment in the OpenShift console (this will trigger the deploy hooks, which run migrations), or re-run the Jenkins pipeline.
Clone this wiki locally