mysql 5.6 备份 脚本

!/bin/bash

数据库用户名

dbuser=’root’

数据库名,可以定义多个数据库,中间以空格隔开,如:test test1 test2

dbname=’cloudmob_ec cloudmob_erp’

password=’cloudmob’

备份时间

backtime=date +%Y%m%d%H%M%S

备份日志路径

logpath= ‘/home/work/workplace/sqlLog/’

数据备份路径

datapath= ‘/home/work/workplace/sql/’

echo ${table}

日志记录头部

for db in $dbname; do

source=mysqldump -u${dbuser} -p${password} ${db}> ${logpath}/${backtime}.sql 2>> ${logpath}/mysqllog.log;

source = mysqldump --defaults-extra-file=/etc/my.cnf ${db}> ${logpath}/${backtime}.sql 2>> ${logpath}/mysqllog.log;

备份成功以下操作

if [ “ ?==0];thencd ? ” == 0 ] ; t h e n c d datapath
zip -r table t a b l e {backtime}.zip backtime.sql>/dev/nullrmf b a c k t i m e . s q l > / d e v / n u l l r m − f {datapath}/${backtime}.sql
fi
done
~

你可能感兴趣的:(mysql 5.6 备份 脚本)