Skip to content

Commit

Permalink
feat: Add schedule for database backup
Browse files Browse the repository at this point in the history
This commit adds a new schedule for database backup in the `.github/workflows/schedule-db-backup.yml` file. The backup will run every night at midnight UTC. It includes jobs to backup test, acceptance, and production environments.
  • Loading branch information
drikusroor committed May 31, 2024
1 parent 9349a31 commit d8b81dd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/schedule-db-backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Schedule Database Backup

on:
schedule:
- cron: '0 0 * * *' # Runs every night at midnight UTC
workflow_dispatch:

jobs:
backup-test:
uses: ./.github/workflows/templates/db-backup.yml
with:
runner: tst

backup-acceptance:
uses: ./.github/workflows/db-backup.yml
with:
runner: ACC

backup-production:
uses: ./.github/workflows/db-backup.yml
with:
runner: PRD
25 changes: 25 additions & 0 deletions .github/workflows/templates/db-backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Database Backup Template

on:
workflow_call:
inputs:
runner:
required: true
type: string

jobs:
backup:
runs-on: ${{ inputs.runner }}
steps:

- name: Set Date
id: date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Backup Database
run: |
podman exec muscle_db_1 sh -c "pg_dump -Fc > /backups/${{ env.DATE }}.dump"
- name: Remove Old Backups (older than 7 days)
run: |
podman exec muscle_db_1 sh -c "find /backups -type f -name '*.dump' -mtime +7 -exec rm {} \;"

0 comments on commit d8b81dd

Please sign in to comment.