Skip to content

Commit

Permalink
Update db dump script to target the new db
Browse files Browse the repository at this point in the history
  • Loading branch information
zuhdil committed Sep 11, 2024
1 parent 79def6e commit 1864745
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 1 addition & 6 deletions scripts/data/helper/make-gcp-dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ fi

gcloud config set project akvo-lumen

gcloud sql export sql rsr-prod-database "gs://akvo-rsr-db-dump/${dump_file}" --database=rsr_db
gcloud sql export sql rsr-prod-database-2024 "gs://akvo-rsr-db-dump/${dump_file}" --database=rsr_db
gsutil cp "gs://akvo-rsr-db-dump/$dump_file" /data/$dump_file
gsutil rm "gs://akvo-rsr-db-dump/$dump_file"

cd /data

# Remove cloudsqlimportexport user
gzip -d $dump_file
sed -i "/cloudsqlimportexport/d" $filename
gzip $filename

# Point db_dump to the last dump
ln -nfs $dump_file db_dump.gz
5 changes: 2 additions & 3 deletions scripts/data/restore-from-dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ psql_settings=("--username=postgres" "--host=${DB_HOST}" "--dbname=${RSR_DB_NAME
psql "${psql_settings[@]}" --command="DROP SCHEMA public CASCADE"
psql "${psql_settings[@]}" --command="CREATE SCHEMA public"
gunzip --stdout "${DUMP_FILE}" \
| sed -e "/rsr_db_test_reportserver_user/d" \
| sed -e "/rsr_db_readonly_reportserver/d" \
| sed -e "/rsr_reportserver_db_user/d" \
| sed -e "/^REVOKE\ /d" \
| sed -e "/^GRANT\ /d" \
| sed -e "/ALTER DEFAULT PRIVILEGES FOR ROLE postgres/d" \
| psql "${psql_settings[@]}"

Expand Down

0 comments on commit 1864745

Please sign in to comment.