Skip to content

Instantly share code, notes, and snippets.

@gzapico
Created June 21, 2017 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gzapico/e897636d246dc9f77b9f3729a85fb3f1 to your computer and use it in GitHub Desktop.
Save gzapico/e897636d246dc9f77b9f3729a85fb3f1 to your computer and use it in GitHub Desktop.
MySQL bash script for backups
#!/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