Mysql备份脚本
#!/bin/bash echo -e [`date +"%Y-%m-%d %H:%M:%S"`] start #system time time=`date +"%y-%m-%d"` #host IP host="127.0.0.1" #database backup user user="root" #database password passwd="yourpasswd" #Create a backup directory mkdir -p /backup/db/"$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 > /backup/db/"$time"/"$i"_"$time".sql done echo -e [`date +"%Y-%m-%d %H:%M:%S"`] end exit 0