-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add schedule for database backup
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
1 parent
9349a31
commit d8b81dd
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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 {} \;" |