Skip to content

Commit

Permalink
add db refresh from paas to aks
Browse files Browse the repository at this point in the history
  • Loading branch information
johnake committed Sep 14, 2023
1 parent daa5df5 commit 6eadaa4
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/restore-paas-db-to-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
options:
- dev

env:
BACKUP_ARTIFACT_NAME: dev-backup

jobs:
backup:
name: Backup from PAAS
Expand Down Expand Up @@ -61,6 +64,68 @@ jobs:
run: |
cf conduit find-a-lost-trn-dev-pg-svc -- pg_dump -E utf8 --clean --compress=1 --if-exists --no-owner --no-privileges --verbose -f backup.sql.gz
- name: Upload backup
uses: actions/upload-artifact@v3
with:
name: ${{ env.BACKUP_ARTIFACT_NAME }}
path: backup.sql.gz
retention-days: 1

restore:
name: Restore to AKS
runs-on: ubuntu-latest
needs: backup

environment: development_aks

env:
ENVIRONMENT_NAME: development_aks

steps:
- uses: actions/checkout@v4

- uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- run: |
test_cluster_rg=s189t01-tsc-ts-rg
test_cluster_name=s189t01-tsc-test-aks
case "${ENVIRONMENT_NAME}" in
development_aks)
echo "cluster_rg=$test_cluster_rg" >> $GITHUB_ENV
echo "cluster_name=$test_cluster_name" >> $GITHUB_ENV
echo "key_vault_name=s189t01-trs-dv-inf-kv" >> $GITHUB_ENV
;;
*)
echo "unknown cluster"
;;
esac
- uses: azure/setup-kubectl@v3

- run: |
az aks get-credentials -g ${{ env.cluster_rg }} -n ${{ env.cluster_name }}
make bin/konduit.sh
- name: Download backup
uses: actions/download-artifact@v3
with:
name: ${{ env.BACKUP_ARTIFACT_NAME }}

- name: Restore database
run: bin/konduit.sh -i backup.sql.gz -c find-a-lost-trn-development -- psql

- name: Remove PaaS event triggers
shell: bash
run: |
bin/konduit.sh find-a-lost-trn-development -- psql -c 'drop event trigger forbid_ddl_reader; drop event trigger make_readable; drop event trigger reassign_owned;'
- uses: geekyeggo/delete-artifact@v2
with:
name: ${{ env.BACKUP_ARTIFACT_NAME }}




Expand Down

0 comments on commit 6eadaa4

Please sign in to comment.