create database olddog;
use olddog;
create table w1(id int);
insert into w1 values(1),(2),(3);
commit;
单库单表备份数据
mysql> select concat("mysqldump -uroot -p123456 ",table_schema," ",table_name," --master-data=2 --singlegle-transaction -R -E --triggers>/backup/",table_schema,"_",table_name,".sql") from information_schema.tables where table_schema not in ('sys','mysql','information_schema','performance_schema') into outfile '/tmp/out.sql';
cat /tmp/out.sql

[root@db01]#sh /tmp/out.sql

单库单表全备

备份后的操作
insert into w1 values(111),(222),(333);
insert into w1 values(11),(22),(33);
commit;

删库
drop table w1;
恢复数据
1截取二进制日志
vim /backup/olddog_w1.sql

mysql> show master status ;

mysql> show binlog events in "mysql-bin.000004";

mysqlbinlog --skip-gtids --include-gtids="ee724332-9432-11ea-9a9d-000c29259def:9-10" /data/mysql/log/binlog/mysql-bin.000004 > /b.sql
mysql> set sql_log_bin=0;
2先恢复单库单表备份数据
mysql> source /backup/olddog_w1.sql
3再恢复二进制日志数据
source /b.sql
