Created
March 11, 2017 15:37
-
-
Save sterndata/99ac86682a2d6529fab06abec5e43949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
export DAY | |
declare DAY=`date|cut -c 1-3` | |
USER="root" | |
PASSWORD="password" | |
MYSQLDUMP="/usr/bin/mysqldump" | |
MYSQL="/usr/bin/mysql" | |
OUTPUTDIR="/home/sdstern/Backup/sugaree/sql" | |
# get a list of databases | |
databases=`$MYSQL --user=$USER --password=$PASSWORD \ | |
-e "SHOW DATABASES;" | tr -d "| " | grep -v Database` | |
for db in $databases; do | |
if [[ "$db" != "information_schema" && "$db" != "performance_schema" ]]; | |
then | |
$MYSQLDUMP --events --user=$USER --password=$PASSWORD --databases $db |gzip > "$OUTPUTDIR/$db-$DAY.sql.gz"; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment