Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ###################################
- # modify here accordingly
- ###################################
- MYSQL_USER="root"
- MYSQL_PASS="password"
- MYSQL_BASE="db"
- EMAIL_FROM="Root<root@domain.com>"
- EMAIL_TO="Some User <someuser@domain.com>"
- ###################################
- # Do not modify below this line
- # if you have no idea what you
- # doing or how this works.
- ###################################
- HOST="$(hostname)"
- NOW="$(date +"%d-%m-%Y")"
- #change this path if needed...
- cd /var/www/
- #backup it up
- mysqldump -u$MYSQL_USER -p$MYSQL_PASS $MYSQL_BASE > $MYSQL_BASE_$NOW.sql
- #compress it and delete the temp file.
- tar -zcvf "Backup"_$NOW.tgz *.sql
- rm *.sql
- #and finally, email it...
- SUBJECT=$MYSQL_BASE" database backup - "$NOW
- EMAILMESSAGE="The $MY_DATABASE database has been backed up on $NOW"
- echo $EMAILMESSAGE | mutt -e "my_hdr From:$EMAIL_FROM" -s "$SUBJECT" -a /var/www/Backup_$NOW.tgz -- "$EMAIL_TO";
Add Comment
Please, Sign In to add comment