Skip to content

Backup database

Backup database #809

Workflow file for this run

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