Skip to content

Commit

Permalink
add service plan arg; remove index processing; scale backup-manager app
Browse files Browse the repository at this point in the history
  • Loading branch information
rshewitt committed Sep 24, 2024
1 parent 1fd8c56 commit 230e5c0
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions docs/backup_restore/catalog-db-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set -o nounset
read -p "Space name> " space_name
read -p "S3 Backup path> " backup_path
read -p "Storage size for new db> " storage_size
read -p "Service plan> " db_plan

function wait_for () {
while ! (cf tasks backup-manager | grep -q "$1 .*SUCCEEDED"); do
Expand All @@ -23,16 +24,12 @@ cf set-env backup-manager DATASTORE_S3_SERVICE_NAME backup-manager-s3
# Go to the correct space
cf target -s $space_name

# # create temp Database
if [[ "${space_name}" == 'prod' ]]; then
db_plan=large-gp-psql-redundant
else
db_plan=large-gp-psql
fi
cf create-service aws-rds ${db_plan} catalog-db-new -c "{\"storage\": ${storage_size}, \"version\": \"12\"}" --wait
cf create-service aws-rds ${db_plan} catalog-db-new -c "{\"storage\": ${storage_size}, \"version\": \"15\"}" --wait
cf bind-service backup-manager catalog-db-new
cf restart backup-manager

cf scale backup-manager -i 1

# # Restore backup
restore_id=$$
cf run-task backup-manager --name "catalog-db-restore-$restore_id" --command "PG_RESTORE_OPTIONS='--no-acl' restore psql catalog-db-new $backup_path"
Expand All @@ -56,12 +53,6 @@ fi
cf rename-service catalog-db catalog-db-venerable
cf rename-service catalog-db-new catalog-db

# clear solr indexes
clear_id=$$
cf run-task catalog-admin --name "clear-solr-index-$clear_id" -c "ckan search-index clear"

wait_for "clear-solr-index-$clear_id"

# bind to new database
cf unbind-service catalog-admin catalog-db-venerable
cf bind-service catalog-admin catalog-db
Expand All @@ -85,8 +76,6 @@ cf unbind-service catalog-fetch catalog-db-venerable
cf bind-service catalog-fetch catalog-db
cf restart catalog-fetch

# reindex solr
cf run-task catalog-admin -c "ckan search-index rebuild -i -o" --name search-index-rebuild -k 2G -m 2G

# cleanup
cf delete-service catalog-db-venerable
cf delete-service catalog-db-venerable
cf scale backup-manager -i 0

0 comments on commit 230e5c0

Please sign in to comment.