ITPub博客

首页 > Linux操作系统 > Linux操作系统 > mysql 利用binlog增量备份、恢复

mysql 利用binlog增量备份、恢复

原创 Linux操作系统 作者:aaqwsh 时间:2010-11-29 13:22:24 0 删除 编辑
1  先全备份:
mysqldump --flush-logs -u root  --all-databases > alldatabase.sql
 
2  进行操作
 
mysql> show master status;
+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| testdb-bin.000062 |      106 |              |                  |
+-------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> select * from t;
+------+
| a    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|    1 |
|    2 |
|    3 |
|    4 |
|    1 |
|    2 |
|    3 |
|    4 |
|    1 |
|    2 |
|    4 |
+------+
15 rows in set (0.00 sec)
mysql> select sysdate();
+---------------------+
| sysdate()           |
+---------------------+
| 2010-11-29 13:31:56 |
+---------------------+
1 row in set (0.00 sec)
mysql> delete from t where a=1;
Query OK, 4 rows affected (0.00 sec)
mysql> select sysdate();
+---------------------+
| sysdate()           |
+---------------------+
| 2010-11-29 13:32:10 |
+---------------------+
1 row in set (0.00 sec)
mysql> show master status;
+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| testdb-bin.000062 |      192 |              |                  |
+-------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
 
3  用全备份恢复
mysql -uroot -pyihaodian  < alldatabase.sql
 
4  查看数据
 
mysql> select * from t;
+------+
| a    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|    1 |
|    2 |
|    3 |
|    4 |
|    1 |
|    2 |
|    3 |
|    4 |
|    1 |
|    2 |
|    4 |
+------+
15 rows in set (0.00 sec)
 
5  执行增加恢复
 mysqlbinlog  --start-date="2010-11-29 13:31:56" --stop-date="2010-11-29 13:32:10"  /var/lib/mysql/testdb-bin.000062 | mysql -u root -p
 
6  查看情况
mysql> select * from t;
+------+
| a    |
+------+
|    2 |
|    3 |
|    4 |
|    2 |
|    3 |
|    4 |
|    2 |
|    3 |
|    4 |
|    2 |
|    4 |
+------+
11 rows in set (0.00 sec)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/758322/viewspace-680533/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 时间同步 - rdate
请登录后发表评论 登录
全部评论

注册时间:2010-11-24

  • 博文量
    132
  • 访问量
    287981