Created
May 14, 2020 02:09
-
-
Save donilan/0097de211cfff8a3a6ad7e42550d8cba to your computer and use it in GitHub Desktop.
dump/backup mysql database in docker way
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
#!/usr/bin/env bash | |
docker run --rm mysql:5.7 mysqldump \ | |
-uUSERNAME \ | |
-hmysq.example.com \ | |
-pPASSWORD database_name | gzip > /path/to/your/backup/folder/backup_$(date +"%Y%m%d_%H%M%S").sql.gz | |
# only keep 5 backups | |
ls -1tr | head -n -5 | xargs -d '\n' rm -f -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment