Oracle: delius_core_development_dev_delius_primarydb_database_backup #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Oracle: Backup" | |
run-name: "Oracle: ${{ (github.event_name == 'workflow_dispatch' && format('{0}_{1}_{2}', github.event.inputs.TargetEnvironment, github.event.inputs.Period, github.event.inputs.TargetHost) || (github.event_name == 'schedule' && format('{0}_{1}_{2}',inputs.TargetEnvironment, inputs.Period, inputs.TargetHost) || 'delius_core_development_dev_delius_primarydb'))}}_database_backup" | |
on: | |
workflow_dispatch: | |
inputs: | |
TargetEnvironment: | |
description: "Target environment" | |
required: true | |
type: choice | |
options: | |
- "delius-core-dev" | |
- "delius-core-test" | |
- "delius-core-training" | |
- "delius-core-stage" | |
- "delius-core-pre-prod" | |
- "delius-core-prod" | |
TargetHost: | |
description: "Backup target host" | |
required: true | |
type: choice | |
options: | |
- "delius_primarydb" | |
- "mis_primarydb" | |
- "misboe_primarydb" | |
- "misdsd_primarydb" | |
- "delius_standbydb1" | |
- "mis_standbydb1" | |
- "misboe_standbydb1" | |
- "misdsd_standbydb1" | |
- "delius_standbydb2" | |
TargetHostList: | |
description: "INTERNAL USE ONLY" | |
type: string | |
default: "delius_primarydb, mis_primarydb, misboe_primarydb, misdsd_primarydb, delius_standbydb1, mis_standbydb1,misboe_standbydb1,misdsd_standbydb1,delius_standbydb2" | |
Period: | |
description: "Is this a daily or weekly backup?" | |
required: true | |
type: choice | |
options: | |
- "daily" | |
- "weekly" | |
FixAbsentChunks: | |
description: "Validate and fix absent S3 missing backup chunks" | |
type: choice | |
default: "yes" | |
options: | |
- "yes" | |
- "no" | |
DeleteDefunct: | |
description: "Delete backups for DBIDs no longer in use" | |
type: choice | |
default: "no" | |
options: | |
- "yes" | |
- "no" | |
EnableTrace: | |
description: "Enable RMAN trace for debugging" | |
required: false | |
type: choice | |
default: "no" | |
options: | |
- "yes" | |
- "no" | |
VerboseOutput: | |
description: "Verbose Output level" | |
type: choice | |
options: | |
- "" | |
- "-v" | |
- "-vv" | |
- "-vvv" | |
- "-vvvv" | |
SourceCodeVersion: | |
description: "Source version for the hmpps-delius-operation-automation. Enter a pull request, branch, commit ID, tag, or reference." | |
type: string | |
default: "main" | |
SourceConfigVersion: | |
description: "Source version for the modernisation-platform-configuration-management. Enter a pull request, branch, commit ID, tag, or reference." | |
type: string | |
default: "main" | |
workflow_call: | |
inputs: | |
TargetEnvironment: | |
description: "Target environment" | |
required: true | |
type: string | |
TargetHost: | |
description: "Backup target host" | |
required: true | |
type: string | |
Period: | |
description: "Is this a daily or weekly backup?" | |
required: true | |
type: string | |
DeleteDefunct: | |
description: "Delete backups for DBIDs no longer in use" | |
required: false | |
type: string | |
default: "no" | |
push: | |
branches: | |
- DBA-531-BACKUP | |
paths: | |
- .github/workflows/oracle-db-backup.yml | |
- playbooks/** | |
# Allow permissions on repository and docker image respectively | |
permissions: | |
contents: read | |
packages: read | |
jobs: | |
prepare_rman_target: | |
runs-on: ubuntu-latest | |
outputs: | |
rman_target: ${{ steps.preparermantarget.outputs.rman_target }} | |
steps: | |
- name: Prepare Rman Target | |
id: preparermantarget | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] | |
then | |
TargetHost="{{ github.event.inputs.TargetHost }}" | |
TargetEnvironment="{{ github.event.inputs.TargetEnvironment }}" | |
elif [[ "${{ github.event_name }}" == "schedule" ]] | |
then | |
TargetHost="{{ inputs.TargetHost }}" | |
TargetEnvironment="{{ inputs.TargetEnvironment }}" | |
else | |
TargetHost="delius_primarydb" | |
TargetEnvironment="delius-core-dev" | |
fi; | |
rman_target='environment_name_$(echo "$TargetEnvironment" | sed 's/delius-core-dev/delius_core_development_dev/;s/delius-core-test/delius_core_test_test/;s/delius-core-training/delius_core_test_training/;s/delius-core-stage/delius_core_preproduction_stage/;s/delius-core-pre-prod/delius_core_preproduction_pre_prod/;s/delius-core-prod/delius_core_production_prod/')_$TargetHost' | |
echo "rman_target=$rman_target" >> $GITHUB_OUTPUT | |
rman_target_output: | |
name: "rman_target" | |
needs: prepare_rman_target | |
runs-on: ubuntu-latest | |
steps: | |
- name: Output | |
run: echo "${{needs.prepare_rman_target.outputs.rman_target}}" | |
# Start deployment container job based on the build delius-ansible-aws image | |
# deployment: | |
# name: "oracle-backup" | |
# environment: "${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.TargetEnvironment || (github.event_name == 'schedule' && inputs.TargetEnvironment )) }}" | |
# runs-on: ubuntu-latest | |
# container: | |
# image: ghcr.io/ministryofjustice/hmpps-delius-operational-automation:0.1 | |
# timeout-minutes: 1440 | |
# env: | |
# backup_command: ansible-playbook operations/playbooks/oracle_backup/backup.yml | |
# validate_command: ansible-playbook operations/playbooks/oracle_backup/validate.yml | |
# delete_dbids_command: ansible-playbook operations/playbooks/oracle_backup/delete_dbids_not_in_use.yml | |
# inventory: inventory/ansible | |
# TargetEnvironment: "${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.TargetEnvironment || (github.event_name == 'schedule' && inputs.TargetEnvironment || (github.event_name == 'push' && 'delius_core_development_dev'))) }}" | |
# TargetHost: "${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.TargetHost || (github.event_name == 'schedule' && inputs.TargetHost || (github.event_name == 'push' && 'delius_primarydb'))) }}" | |
# Period: "${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.Period || (github.event_name == 'schedule' && inputs.Period || (github.event_name == 'push' && 'daily'))) }}" | |
# FixAbsentChunks: "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.FixAbsentChunks || 'yes' }}" | |
# DeleteDefunct: "${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.DeleteDefunct || (github.event_name == 'schedule' && inputs.DeleteDefunct || 'no')) }}" | |
# EnableTrace: "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.EnableTrace || 'no' }}" | |
# VerboseOutput: "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.VerboseOutput || '' }}" | |
# continue-on-error: false | |
# steps: | |
# - name: Checkout hmpps-delius-operation-automation | |
# uses: actions/checkout@v4 | |
# with: | |
# sparse-checkout-cone-mode: false | |
# sparse-checkout: | | |
# playbooks/oracle_backup | |
# path: operations | |
# ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.SourceCodeVersion || 'main' }} | |
# fetch-depth: 0 | |
# - name: Checkout modernisation-platform-configuration-management | |
# uses: actions/checkout@v4 | |
# with: | |
# repository: ministryofjustice/modernisation-platform-configuration-management | |
# sparse-checkout-cone-mode: false | |
# sparse-checkout: | | |
# ansible/hosts | |
# ansible/group_vars | |
# path: inventory | |
# ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.SourceConfigVersion || 'main' }} | |
# fetch-depth: 0 | |
# - name: Configure AWS Credentials | |
# id: login-aws | |
# uses: aws-actions/configure-aws-credentials@v4 | |
# with: | |
# aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY }} | |
# aws-secret-access-key: ${{ secrets.CICD_SECRET_ACCESS_KEY }} | |
# aws-region: ${{ secrets.AWS_REGION }} | |
# delius-core-dev => delius_core_development_dev | |
# - name: Start Ansible Backup | |
# run: $backup_command -i $inventory -e rman_target="environment_name_${{env.TargetEnvironment}}_${{env.TargetHost}}" -e daily_weekly=$Period -e enable_trace=$EnableTrace $VerboseOutput | |
# - name: Start Ansible Validate And Fix Absent Chunks | |
# run: $validate_command -i $inventory -e rman_target="environment_name_${{env.TargetEnvironment}}_${{env.TargetHost}}" -e fix_absent_chunks=$FixAbsentChunks $VerboseOutput | |
# - name: Start Ansible Delete DBIDs Not In Use | |
# if: ${{ env.DeleteDefunct == 'yes' }} | |
# run: $delete_dbids_command -i $inventory -e rman_target="environment_name_${{env.TargetEnvironment}}_${{env.TargetHost}}" $VerboseOutput | |