Created
June 21, 2017 16:18
-
-
Save gzapico/e897636d246dc9f77b9f3729a85fb3f1 to your computer and use it in GitHub Desktop.
MySQL bash script for backups
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
#!/bin/sh | |
DBSERVER= | |
DATABASE= | |
FILE=${DATABASE}-`date +"%Y%m%d"` | |
USER= | |
PASS= | |
unalias rm 2> /dev/null | |
rm ${FILE} 2> /dev/null | |
rm ${FILE}.gz 2> /dev/null | |
mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE} 2> /dev/null | |
gzip $FILE | |
echo "${FILE}.gz was created" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment