Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

How to switch shared pqsl service to medium psql redundant

Priya Kasireddy edited this page Sep 13, 2023 · 6 revisions

Ref: Backup or Restore Wagtail PostgreSQL database in dev, staging, or production

--[1] install connect-to-service plugin (after install cf CLI)

(on Mac)

cf install-plugin https://github.com/cloud-gov/cf-service-connect/releases/download/1.1.3/cf-service-connect-darwin-amd64

To uninstall a plugin, run this command: cf uninstall-plugin <plugin name>

 

--[2] create new db service

cf create-service aws-rds medium-psql-redundant <service_name>

 

--[3] connect the existing db to dump file (leave this open)

cf connect-to-service -no-client <app_name> <existing_service_name>

 

--[4] (open separated terminal) dump the existing db file to local

pg_dump -F c --no-acl --no-owner -f fec_eregs_prod_<date>.dump postgres://<username>:<password>@<host>:<port>/<name>

 

--[5] bind new db service to app (init bind, don't restage)

cf bind-service <app_name> <service_name>

 

--[6]connect new db service

cf connect-to-service -no-client <app_name> <new_service_name>

 

--[7] restore data into new db((ignore 3 extension warnings)

pg_restore --dbname postgres://<username>:<password>@<host>:<port>/<name> --no-acl --no-owner <file name>

 

--[8] switch bind app to new db

modify manifest_.yml file and push

===============================

 

------How to delete the old instance

** 1) unbind instance from app (if bound an app)**
cf unbind-service <app_name> <instance_name>

** 2) Get service key name of instance **
cf sk <instance_name>

** 3) Delete service key **
cf delete-service-key <instance_name> <service key name get from step 2)>

** 4) Delete the service **
cf delete-service <instance_name>

===============================

------How to install Postgresql 11.x

1)go to https://www.enterprisedb.com/downloads/postgres-postgresql-downloads download: postgresql-11.x-x-osx.dmg and install on Mac (uncheck: Stack Builder)

2)default install location: /Library/PostgreSQL/11

3)dump: /Library/PostgreSQL/11/bin/pg_dump -F c --no-acl --no-owner -f <dump_file_name>.dump postgres://<user_name>:@localhost:/<database_name>

4)restore: /Library/PostgreSQL/11/bin/pg_restore --dbname postgres://<user_name>:@localhost:/<database_name> --no-acl --no-owner <dump_file_name>.dump