From b16d3790f2d5e3a22c2c251e17d2cce0303dd05f Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Wed, 23 Oct 2024 13:10:18 +0100 Subject: [PATCH] restore database --- .github/workflows/database-restore.yml | 66 +++++++++++++------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/database-restore.yml b/.github/workflows/database-restore.yml index 655dfd8b..b47cefa2 100644 --- a/.github/workflows/database-restore.yml +++ b/.github/workflows/database-restore.yml @@ -9,17 +9,17 @@ on: default: development type: choice options: - - development - - test - - production + - development + - test + - production confirm-production: description: Must be set to true if restoring production required: true - default: 'false' + default: "false" type: choice options: - - 'false' - - 'true' + - "false" + - "true" backup-file: description: Name of the backup file in Azure storage. e.g. aytq_prod_2024-08-09.sql.gz. The default value is today's scheduled backup. type: string @@ -39,32 +39,32 @@ jobs: concurrency: deploy_${{ inputs.environment }} steps: - - uses: actions/checkout@v4 - name: Checkout + - uses: actions/checkout@v4 + name: Checkout - - name: Set environment variables - run: | - source global_config/${{ inputs.environment }}.sh - tf_vars_file=${{ env.TF_VARS_PATH }}/${{ inputs.environment }}.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 - echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV - echo "DB_SERVER=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-pg" >> $GITHUB_ENV - TODAY=$(date +"%F") - echo "BACKUP_FILE=${SERVICE_SHORT}_${CONFIG_SHORT}_${TODAY}.sql" >> $GITHUB_ENV - if [ "${{ inputs.backup-file }}" != "" ]; then - BACKUP_FILE=${{ inputs.backup-file }} - else - BACKUP_FILE=${SERVICE_SHORT}_${CONFIG_SHORT}_${TODAY}.sql.gz - fi - echo "BACKUP_FILE=$BACKUP_FILE" >> $GITHUB_ENV + - name: Set environment variables + run: | + source global_config/${{ inputs.environment }}.sh + tf_vars_file=${{ env.TF_VARS_PATH }}/${{ inputs.environment }}.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 + echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV + echo "DB_SERVER=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-pg" >> $GITHUB_ENV + TODAY=$(date +"%F") + echo "BACKUP_FILE=${SERVICE_SHORT}_${CONFIG_SHORT}_${TODAY}.sql" >> $GITHUB_ENV + if [ "${{ inputs.backup-file }}" != "" ]; then + BACKUP_FILE=${{ inputs.backup-file }} + else + BACKUP_FILE=${SERVICE_SHORT}_${CONFIG_SHORT}_${TODAY}.sql.gz + fi + echo "BACKUP_FILE=$BACKUP_FILE" >> $GITHUB_ENV - - name: Restore ${{ inputs.environment }} postgres - uses: DFE-Digital/github-actions/restore-postgres-backup@master - with: - storage-account: ${{ env.STORAGE_ACCOUNT_NAME }} - resource-group: ${{ env.RESOURCE_GROUP_NAME }} - app-name: ${{ env.SERVICE_NAME }}-${{ inputs.environment }} - cluster: ${{ env.CLUSTER }} - azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} - backup-file: ${{ env.BACKUP_FILE }} + - name: Restore ${{ inputs.environment }} postgres + uses: DFE-Digital/github-actions/restore-postgres-backup@master + with: + storage-account: ${{ env.STORAGE_ACCOUNT_NAME }} + resource-group: ${{ env.RESOURCE_GROUP_NAME }} + app-name: ${{ env.SERVICE_NAME }}-${{ inputs.environment }} + cluster: ${{ env.CLUSTER }} + azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} + backup-file: ${{ env.BACKUP_FILE }}