Skip to content

Commit

Permalink
backup workflow testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RMcVelia committed Oct 30, 2024
1 parent f1d9c75 commit 9e704f5
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/database-backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ jobs:
inlineScript: |
az postgres flexible-server firewall-rule create --name ${{ env.POSTGRES_SERVER_NAME }} --resource-group ${{ env.RESOURCE_GROUP_NAME }} --rule-name Allow-GithubRunner-Postgres --start-ip-address ${{ env.RUNNER_IP }} --end-ip-address ${{ env.RUNNER_IP }}
- name: Add PG PASS
shell: bash
run: |
echo '${{ env.POSTGRES_SERVER_HOST_NAME }}:5432:${{ env.POSTGRES_DATABASE_NAME }}:${{ steps.get_infrastructure_secrets.outputs.POSTGRES_ADMIN_USERNAME }}:${{ steps.get_infrastructure_secrets.outputs.POSTGRES_ADMIN_PASSWORD }}' >> ~/.pgpass
chmod 600 ~/.pgpass
# - name: Add PG PASS
# shell: bash
# run: |
# echo '${{ env.POSTGRES_SERVER_HOST_NAME }}:5432:${{ env.POSTGRES_DATABASE_NAME }}:${{ steps.get_infrastructure_secrets.outputs.POSTGRES_ADMIN_USERNAME }}:${{ steps.get_infrastructure_secrets.outputs.POSTGRES_ADMIN_PASSWORD }}' >> ~/.pgpass
# chmod 600 ~/.pgpass

- name: Run PG Dump
shell: bash
run: |
export PGSSLMODE=require
pg_dump -Fc -v --host=${{ env.POSTGRES_SERVER_HOST_NAME }} --port=5432 --username=${{ steps.get_infrastructure_secrets.outputs.POSTGRES_ADMIN_USERNAME }} --dbname=${{ env.POSTGRES_DATABASE_NAME }} > ${{ env.BACKUP_FILE_NAME }}.sql
zip -r ${{ env.BACKUP_FILE_NAME }}.sql.zip ${{ env.BACKUP_FILE_NAME }}.sql
# - name: Run PG Dump
# shell: bash
# run: |
# export PGSSLMODE=require
# pg_dump -Fc -v --host=${{ env.POSTGRES_SERVER_HOST_NAME }} --port=5432 --username=${{ steps.get_infrastructure_secrets.outputs.POSTGRES_ADMIN_USERNAME }} --dbname=${{ env.POSTGRES_DATABASE_NAME }} > ${{ env.BACKUP_FILE_NAME }}.sql
# zip -r ${{ env.BACKUP_FILE_NAME }}.sql.zip ${{ env.BACKUP_FILE_NAME }}.sql

- name: Delete firewall rule
if: always()
Expand All @@ -88,20 +88,20 @@ jobs:
inlineScript: |
az postgres flexible-server firewall-rule delete --name ${{ env.POSTGRES_SERVER_NAME }} --resource-group ${{ env.RESOURCE_GROUP_NAME }} --rule-name Allow-GithubRunner-Postgres --yes
- name: Upload Backup to Azure Storage
run: |
az storage blob upload --container-name get-an-identity \
--file ${BACKUP_FILE_NAME}.sql.zip --name ${BACKUP_FILE_NAME}.sql.zip \
--connection-string '${{ steps.get_storage_secret.outputs.BACKUP-STORAGE-CONNECTION-STRING }}' \
--overwrite true
# - name: Upload Backup to Azure Storage
# run: |
# az storage blob upload --container-name get-an-identity \
# --file ${BACKUP_FILE_NAME}.sql.zip --name ${BACKUP_FILE_NAME}.sql.zip \
# --connection-string '${{ steps.get_storage_secret.outputs.BACKUP-STORAGE-CONNECTION-STRING }}' \
# --overwrite true

- name: Notify Slack channel on job failure
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: CI Deployment
SLACK_TITLE: Database backup failure
SLACK_MESSAGE: Production database backup job failed. Also check the azure postgres server firewall rules.
SLACK_WEBHOOK: ${{ steps.get_monitoring_secret.outputs.SLACK_WEBHOOK }}
SLACK_COLOR: failure
SLACK_FOOTER: Sent from backup job in database-backup workflow
# - name: Notify Slack channel on job failure
# if: failure()
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_USERNAME: CI Deployment
# SLACK_TITLE: Database backup failure
# SLACK_MESSAGE: Production database backup job failed. Also check the azure postgres server firewall rules.
# SLACK_WEBHOOK: ${{ steps.get_monitoring_secret.outputs.SLACK_WEBHOOK }}
# SLACK_COLOR: failure
# SLACK_FOOTER: Sent from backup job in database-backup workflow

0 comments on commit 9e704f5

Please sign in to comment.