Skip to content

Oracle: Schedule Backups #239

Oracle: Schedule Backups

Oracle: Schedule Backups #239

name: "Oracle: Schedule Backups"
on:
schedule:
- cron: '0 7 * * 1,2,4,5'
- cron: '0 7 * * 3'
- cron: '30 6 * * 3'
jobs:
prepare-run-matrix:
runs-on: ubuntu-latest
outputs:
scheduled_matrix: ${{ steps.filter-backups-schedule.outputs.scheduling_matrix }}
steps:
- name: Checkout Backups Schedule
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
.github/workflows/oracle-db-backups-schedule.json
path: operations
ref: main
fetch-depth: 0
- name: Filter Backups Schedule
id: filter-backups-schedule
run: |
SCHEDULED_JSON=$(jq '[.[] | select (.CronSchedule=="${{ github.event.schedule }}") | {"TargetEnvironment","TargetHost","Period"}]' operations/.github/workflows/oracle-db-backups-schedule.json | jq '{include: .}')
echo "scheduling_matrix="$(echo ${SCHEDULED_JSON} | sed 's/ //g') >> $GITHUB_OUTPUT
report-schedule-backup:
needs: prepare-run-matrix
runs-on: ubuntu-latest
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix != '{"include":[]}' }}
steps:
- name: Report Backups Scheduled to Run
id: report-run
run: |
echo "Running Backups for these targets: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix }}"
report-no-scheduled-backup:
needs: prepare-run-matrix
runs-on: ubuntu-latest
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix == '{"include":[]}' }}
steps:
- name: Report Nothing to Do
id: report-no-run
run: |
echo "No targets scheduled for backup run."
run-backup:
needs: prepare-run-matrix
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix != '{"include":[]}' }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prepare-run-matrix.outputs.scheduled_matrix)}}
name: "run-${{ format('{0}-{1}-{2}', matrix.TargetEnvironment, matrix.Period, matrix.TargetHost) }}-backup"
uses:
ministryofjustice/hmpps-delius-operational-automation/.github/workflows/oracle-db-backup.yml@main
with:
TargetEnvironment: ${{ matrix.TargetEnvironment }}
TargetHost: ${{ matrix.TargetHost }}
Period: ${{ matrix.Period }}
secrets: inherit