Skip to content

Instantly share code, notes, and snippets.

@memandip
Created February 7, 2021 10:43
Show Gist options
  • Save memandip/19f5ab40dd1b7be13951100f366384c3 to your computer and use it in GitHub Desktop.
Save memandip/19f5ab40dd1b7be13951100f366384c3 to your computer and use it in GitHub Desktop.
Bash script to backup MySQL data
#!/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