**时间点恢复例子**
mysqldump -uroot  -p mydb > /root/mydb-`date +"%F"`.sql
//添加数据
use mydb;
CREATE TABLE t1(name CHAR(20));
INSERT INTO t1 VALUES ('Tom'),('Jerry');
DESC stu;
INSERT INTO stu(name,age) VALUES ('Flyn',18);
SELECT * FROM stu;
//删除数据库
service mysqld stop
cd /data/
mv mydb /tmp
cp mysql-bin.000009 /root
service mysqld start
//查看数据库,发现数据库丢失
SHOW DATABASES;

SHOW BINLOG EVENTS IN 'mysql-bin.000009'\G;
mysqlbinlog /data/mysql-bin.000009

//创建数据库
CREATE DATABASE mydb;
//数据库恢复
mysqlbinlog  --start-position 106 --stop-position 504  /data/mysql-bin.000009 > /tmp/mydbrestore.sql
mysql -uroot -p  < /tmp/mydbrestore.sql


  **快照物理备份(时间点备份)**
fdisk /dev/sda
partprobe /dev/sda
pvcreate /dev/sda{5,6}
vgcreate vg0 /dev/sda{5,6}
lvcreate -L 2G -n mydata vg0
mke2fs -j /dev/vg0/mydata
mkdir /mydata
mount /dev/vg0/mydata /mydata
cp -rp /data/* /mydata
cd /mydata

chown mysql.mysql /mydata    //重要
sevice mysqld stop
vim /etc/my.cnf
datadir = /mydata 
service mysqld start

mysql
FLUSH TABLES WITH READ LOCK;
FLUSH LOGS;
lvcreate -L 20M -s -n mysnap /dev/vg0/mydata

mysql
UNLOCK TABLES;
mkdir /mysnap
mount /dev/vg0/mysnap /mysnap
cd /mysnap

mysql
use mydb;
SELECT * FROM t1;
INSERT INTO t1 VALUES ('Wendy'),('Sandy'),('Sunny')
cp -rp /mysnap/mydb /tmp/mydb

umount /mysnap
lvremove /dev/vg0/mysnap

//演示数据丢失
mysql
FLUSH LOGS;
DROP DATABASE mydb;

cd /mydata
service mysqld stop
cp -rp /tmp/mydb mydb
service mysqld start

mysql
SHOW DATABASES;
use mydb;
SELECT * FROM t1;
SHOW BINLOG EVENTS IN 'mysql-bin.000013';
//数据恢复
mysqlbinlog --start-position 106 --stop-position 220 mysql-bin.000013 > /tmp/a.sql
mysql -uroot -p < /tmp/a.sql

mysql
USE mydb;
SELECT * FROM t1;