Created
February 7, 2021 10:43
-
-
Save memandip/19f5ab40dd1b7be13951100f366384c3 to your computer and use it in GitHub Desktop.
Bash script to backup MySQL data
This file contains hidden or 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
#!/bin/bash | |
monthname=$(date +%b) | |
monthdayname=$(date +%d) | |
yearname=$(date +%Y) | |
hour=$(date +%H) | |
minute=$(date +%M) | |
exportname="db_backup_${monthname}_${monthdayname}_${yearname}_${hour}_${minute}.sql" | |
// You may need to pass db credentials depending on your mysql-server setup | |
mysqldump db_name > "db_data/${exportname}" | |
echo "DB backup complete. filename=${exportname}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment