Skip to content

Instantly share code, notes, and snippets.

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 jamesbrooks/182703 to your computer and use it in GitHub Desktop.
Save jamesbrooks/182703 to your computer and use it in GitHub Desktop.
#!/bin/bash
# configuration
PROJECT_NAME='Foo'
PATH_TO_BACKUPS='/backups/foo_database_backups'
RECIPIENT_EMAIL='james@whatever.com'
DATABASE_USERNAME='root'
DATABASE_PASSWORD='password'
DATABASE_DATABASE='database_name'
# end of configuration. should not need to edit from this point
TIMESTAMP=`date +%F_%T`
OUTFILE="$PATH_TO_BACKUPS/$TIMESTAMP.sql"
mysqldump -u$DATABASE_USERNAME -p$DATABASE_PASSWORD $DATABASE_DATABASE > $OUTFILE
bzip2 $OUTFILE
mutt -a $OUTFILE.bz2 -s "Database/$PROJECT_NAME for $TIMESTAMP" $RECIPIENT_EMAIL < /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment