MySQL 多实例数据库还原脚本-备份集与端口对应

时间:2021-08-07 06:10:02

版本:5.5.14

OS: ConetOS 6.3

1、创建recover.sh

[root@yoon  export]# vi  recover.sh

#!/bin/bash

bakdir=/export/data
mysql=/export/servers/mysql/bin/mysql
user=root
passwd=123456

for port in {3361..3362}
do
 ($mysql -u$user -p$passwd -S /export/data/mysql/tmp/mysql$port.sock < `cat /home/mysql/bakinfo|grep $port|awk -F, '{print $2}'`) &
done

2、创建bakinfo文件

[root@yoon  export]#  vi   bakinfo

3361,/export/backup/all.255.10-2014-03-31.sql
3362,/export/backup/all.255.11-2014-03-31.sql