Guest User

Untitled

a guest
Aug 31st, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ###################################
  4. # modify here accordingly
  5. ###################################
  6. MYSQL_USER="root"
  7. MYSQL_PASS="password"
  8. MYSQL_BASE="db"
  9.  
  10. EMAIL_FROM="Root<root@domain.com>"
  11. EMAIL_TO="Some User <someuser@domain.com>"
  12.  
  13. ###################################
  14. # Do not modify below this line
  15. # if you have no idea what you
  16. # doing or how this works.
  17. ###################################
  18. HOST="$(hostname)"
  19. NOW="$(date +"%d-%m-%Y")"
  20.  
  21. #change this path if needed...
  22. cd /var/www/
  23.  
  24. #backup it up
  25. mysqldump -u$MYSQL_USER -p$MYSQL_PASS $MYSQL_BASE > $MYSQL_BASE_$NOW.sql
  26.  
  27. #compress it and delete the temp file.
  28. tar -zcvf "Backup"_$NOW.tgz *.sql
  29. rm *.sql
  30.  
  31. #and finally, email it...
  32. SUBJECT=$MYSQL_BASE" database backup - "$NOW
  33. EMAILMESSAGE="The $MY_DATABASE database has been backed up on $NOW"
  34.  
  35. 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