shell 分库分表备份

[[email protected] ~]# cat mydump.sh
#!/bin/bash
mysqldump=“mysql -uroot -p123456 -S /tmp/mysql.sock1”
for dbname in $mysqldump -e "show databases" 2>/dev/null |egrep -v "Database|schema"
do
echo $dbname
#分库备份
mysqldump -uroot -p123456 -S /tmp/mysql.sock1 --databases dbname>/tmp/dbname > /tmp/dbname.sql
#分表备份
mysql -uroot -p123456 -S /tmp/mysql.sock1 -e “show tables from $dbname;” 2>/dev/null |sed ‘1d’ >> /tmp/tables.txt
while read table
do
echo $table
mysqldump -uroot -p123456 -S /tmp/mysql.sock1 $dbname table>/tmp/table >/tmp/dbname_$table.sql
done < /tmp/tables.txt
done
shell 分库分表备份

相关文章:

  • 2021-08-24
  • 2022-12-23
  • 2021-05-23
  • 2021-10-16
  • 2022-03-02
猜你喜欢
  • 2021-04-14
  • 2022-01-13
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案