Backup database #82
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: Backup database | |
on: | |
schedule: | |
- cron: '0 4,14 * * *' | |
workflow_call: | |
secrets: | |
DB_PASSWORD: | |
required: true | |
workflow_dispatch: | |
jobs: | |
dump: | |
runs-on: [self-hosted, linux] | |
environment: Production | |
env: | |
DB_NAME: ${{ vars.DB_NAME }} | |
DB_USER: ${{ vars.DB_USER }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
steps: | |
- name: Make dump directory | |
run: mkdir -p ~/$DB_NAME | |
- name: Dump database | |
run: docker exec clubbdmanga-db-1 mariadb-dump -u $DB_USER --password=$DB_PASSWORD $DB_NAME > ~/$DB_NAME/$(date +"%s").sql | |
- name: Delete dumps older than 30 days | |
run: find ~/$DB_NAME -type f -mtime +30 -delete |