* 6 * * * mysql /home/mysql/autobackup.sh &> /dev/null

#!/bin/bash
echo -e [`date +"%Y-%m-%d %H:%M:%S"`] start
#system time
time=`date +"%y-%m-%d"`
#host IP
host="1.2.3.4″
#database backup user
user="root"
#database password
passwd="passwd"
#Create a backup directory
mkdir -p /home/mysql/backup/"$time"
#list database name
all_database=`/usr/bin/mysql -u$user -p$passwd -Bse ‘show databases’`
#in the table from the database backup
for i in $all_database
do
/usr/bin/mysqldump -u$user -p$passwd $i > /home/mysql/backup/"$time"/"$i"_"$time".sql
done
echo -e [`date +"%Y-%m-%d %H:%M:%S"`] end
exit 0