#!/bin/bash

MYUSER=root

MYPASS=123456

SOCKET=/data/3306/mysql.sock

MYCMD="mysql -u$MYUSER -p$MYPASS -S $SOCKET"

BAKPATH="/backup/$(date +%F)"


[ ! -d $BAKPATH ] && mkdir -p $BAKPATH

for dbname in `$MYCMD -e 'show databases;'|sed '1d'|grep -v "_schema"`

  do

    $MYDUMP -B -x --events $dbname|gzip >$BAKPATH/${dbname}.sql.gz

    if [ $? -eq 0 ];then

      echo "$dbname" >>$BAKPATH/${dbname}.log

    fi

  done