Skip to content

Test: Add recover db workflow #1

Test: Add recover db workflow

Test: Add recover db workflow #1

name: Recover deleted postgres database server
on:
workflow_dispatch:
inputs:
environment:
description: Environment to restore
required: true
default: test
type: choice
options:
- test
- preprod
- production
confirm-production:
description: Must be set to true if restoring production
required: true
default: "false"
type: choice
options:
- "false"
- "true"
restore-time:
description: Restore point in time in UTC. e.g. 2024-07-24T06:00:00. This is required and should be at least 10 minutes after the server was deleted.
type: string
required: true
deleted-server:
description: This should be the name of the deleted postgres server. ex. s189t01-afqts-ts-pg
required: true
type: string
push:
branches:
- add-recover-db-workflow
env:
SERVICE_SHORT: afqts
TF_VARS_PATH: terraform/application/config
permissions:
id-token: write
jobs:
recover-deleted-postgres:
name: Recover Deleted Postgres
# if: ${{ inputs.environment != 'production' || (inputs.environment == 'production' && github.event.inputs.confirm-production == 'true' ) }}
runs-on: ubuntu-latest
environment: test # ${{ inputs.environment }}
concurrency: deploy_test # ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
- name: Set environment variables
run: |
# source global_config/${{ inputs.environment }}.sh
# tf_vars_file=${TF_VARS_PATH}/${{ inputs.environment }}.tfvars.json
source global_config/test.sh
tf_vars_file=${TF_VARS_PATH}/test.tfvars.json
echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV
echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV
# DELETED_DB_SERVER="${{ inputs.deleted-server }}"
DELETED_DB_SERVER="s189t01-afqts-ts-pg-ptr-devops"
echo "DELETED_DB_SERVER=${DELETED_DB_SERVER}" >> $GITHUB_ENV
- name: Recover deleted postgres for ${{ inputs.environment }} environment
uses: DFE-Digital/github-actions/restore-deleted-postgres@master
with:
resource-group: ${{ env.RESOURCE_GROUP_NAME }}
deleted-server: ${{ env.DELETED_DB_SERVER }}
restore-time: "2025-08-27T13:05:00" # ${{ inputs.restore-time }}
cluster: ${{ env.CLUSTER }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}