Skip to content

Instantly share code, notes, and snippets.

@salomvary
Last active February 8, 2024 19:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save salomvary/836afdbc137364c73631aa6845d091c1 to your computer and use it in GitHub Desktop.
Save salomvary/836afdbc137364c73631aa6845d091c1 to your computer and use it in GitHub Desktop.
GitHub Action for mysqldump
name: backup-mysql
on:
schedule:
# Run at 7:00 UTC every day
- cron: "0 7 * * *"
jobs:
run_mysqldump:
runs-on: ubuntu-latest
steps:
- name: Dump database
env:
MYSQL_PWD: ${{ secrets.MYSQL_PWD }}
run: |
mysqldump \
-u my-user \
-h some.host.example.com \
-P 4242 \
--verbose \
very_important_database \
| bzip2 -c > latest.sql.bz2
- name: Archive database dump
uses: actions/upload-artifact@v2
with:
name: latest.sql.bz2
path: latest.sql.bz2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment