mysqldump本身不支持这种写法,你能做的是使用多个程序串联起来。具体原理是先使用mysql读出所有的table,然后用grep过滤,然后传给mysqldump。你可能需要用到这么几个命令mysql,grep,xargs,mysqldump
#/bin/bash
#定义变量名USER="pubselect"
PASSWD="123pubselect"
HOST="101.201.119.118"
TIME=`date +%Y%m%d`
#判断备份目录是否存在不存在就创建
if [ ! -d mysql.bak/ ] ;then
mkdir /root/mysql.bak
exit
fi
echo " " >> /root/mysql.bak/mysql.$TIME
echo " " >> /root/mysql.bak/mysql.$TIME
echo "-------------------------------------------" >>/root/mysql.bak/mysql.$TIME
#查找库里面相同前缀的表格并将其备份出来
bak=$(mysql -upubselect -h101.201.119.118 -p123pubselect -e "use sfsms;show tables;"|grep arptjnl20*)
for t in $bak;
do
mysqldump -u pubselect -p123pubselect -h 101.201.119.118 --skip-lock-tables sfsms $t
>/root/mysql.bak/mysql.$TIME
done