#!/bin/sh
MYUSER=root
MYPASS=123123
MYSOCK=/tmp/mysql.sock
backup_path=/test
DBLIST="`mysql -u$MYUSER -p$MYPASS -e "show databases;" |grep -Ev ‘Database|mysql|schema‘`"
DUMP="mysqldump -u$MYUSER -p$MYPASS -F -R -x"
mkdir -p $backup_path
for db in $DBLIST
do
echo "db:"$db
TBLIST="$(mysql -u$MYUSER -p$MYPASS -e "show tables from $db;" |sed 1d)"
for tb in $TBLIST
do
$DUMP $db $tb |gzip >${backup_path}/mysqltest_${db}_${tb}_$(date +%F).sql.gz
echo "table:"$tb
done
done
时间: 2024-10-09 05:50:49