Skip to content

Commit

Permalink
Add workflow to backup production DB
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad committed Nov 20, 2023
1 parent 0a8a8d1 commit 1cc8cad
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/backup-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Backup production database

on:
workflow_dispatch:
schedule:
- cron: "0 4 * * *" # 04:00 UTC
push:
branches:
- backup-db

jobs:
backup:
name: Backup database
runs-on: ubuntu-latest

environment: production

steps:
- uses: actions/checkout@v4

- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.0
terraform_wrapper: false

- uses: DFE-Digital/github-actions/set-arm-environment-variables@master
with:
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}

- name: Get Azure backup storage details
id: azure-backup-storage
run: |
set -e
#make ci production_aks terraform-init
make ci production_aks
terraform -chdir=terraform/aks init -backend-config workspace_variables/production.backend.tfvars -reconfigure -input=false
echo "account-name=$(terraform -chdir=terraform/aks output -raw postgres_azure_backup_storage_account_name)" >> $GITHUB_OUTPUT
echo "container-name=$(terraform -chdir=terraform/aks output -raw postgres_azure_backup_storage_container_name)" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ terraform-init:
$(eval export TF_VAR_azure_resource_prefix=$(RESOURCE_NAME_PREFIX))

[[ "${SP_AUTH}" != "true" ]] && az account set -s $(AZURE_SUBSCRIPTION) || true
terraform -chdir=terraform/$(PLATFORM) init -backend-config workspace_variables/${DEPLOY_ENV}.backend.tfvars -reconfigure
terraform -chdir=terraform/$(PLATFORM) init -backend-config workspace_variables/${DEPLOY_ENV}.backend.tfvars -reconfigure -input=false

terraform-plan: terraform-init # make [env] terraform-plan init
terraform -chdir=terraform/$(PLATFORM) plan -var-file workspace_variables/${DEPLOY_ENV}.tfvars.json
Expand Down
7 changes: 7 additions & 0 deletions terraform/aks/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "postgres_azure_backup_storage_account_name" {
value = module.postgres.azure_backup_storage_account_name
}

output "postgres_azure_backup_storage_container_name" {
value = module.postgres.azure_backup_storage_container_name
}

0 comments on commit 1cc8cad

Please sign in to comment.