MySQL分庫分表備份

#!/bin/bash
#分庫分表備份
#by anthors lrj 2016-6-15
mkdir -p /bash_shell/test_file/$(date +%F)mysql

for db_name in mysql -e "show databases"|sed '1,2d';do #取庫名
for table_name in mysql -e "show tables from $db_name;"|sed '1d';do #取表名
mkdir -p /bash_shell/test_file/$(date +%F)/$db_name
/usr/bin/mysqldump --lock-tables=0 ${db_name} $table_name|gzip >/bash_shell/test_file/$(date +%F)/$db_name/${dbname}${tablename}$(date +%F).sql.gz
done
donesql

相關文章
相關標籤/搜索