Skip to content

Instantly share code, notes, and snippets.

@Ditti4
Created June 26, 2013 07:00
Show Gist options
  • Save Ditti4/5865324 to your computer and use it in GitHub Desktop.
Save Ditti4/5865324 to your computer and use it in GitHub Desktop.
Just a simple script to backup all databases of a MySQL/MariaDB server and send it with mutt to an specified mail address.
#!/bin/bash
# This file is licensed under the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004
# See http://www.wtfpl.net/txt/copying/
password=''
mail=''
date=$(date +%m_%d_%Y%H_%M_%S)
mysqldump --add-drop-database --flush-privileges --all-databases -u root -p${password} > /backup/sql/${date}.sql
echo "See the attachment for the backup. Have fun!"|mutt -s "MySQL backup" -a /backup/sql/${date}.sql ${mail}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment