mysql 利用binlog增量備份、恢復
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)
+-------------------+----------+--------------+------------------+
| 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)
+------+
| 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)
+---------------------+
| 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)
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)
+---------------------+
| 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)
+-------------------+----------+--------------+------------------+
| 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)
+------+
| 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)
+------+
| a |
+------+
| 2 |
| 3 |
| 4 |
| 2 |
| 3 |
| 4 |
| 2 |
| 3 |
| 4 |
| 2 |
| 4 |
+------+
11 rows in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-680533/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- rman 增量備份恢復
- oracle 增量備份恢復驗證Oracle
- 利用binlog日誌恢復mysql資料MySql
- 用增量備份來快速恢復dg
- Mysql備份恢復MySql
- 【Xtrabackup】Xtrabackup全備、增量備份及恢復示例
- 【MySQL】MySQL備份和恢復MySql
- MySQL備份與恢復——基於Xtrabackup物理備份恢復MySql
- MySQL 備份與恢復MySql
- 基於percona xtrabackup 2.4.14的增量備份恢復還原mysql 5.6MySql
- Mysql備份與恢復(1)---物理備份MySql
- MySQL備份與恢復——基於MyDumper/MyLoader 邏輯備份恢復MySql
- MySQL 非常規恢復與物理備份恢復MySql
- Mysql備份與恢復(2)---邏輯備份MySql
- dg丟失歸檔,使用rman增量備份恢復
- 利用innobackupex備份集恢復指定庫
- MySQL備份與恢復——基於OUTFILE /LOAD DATA 邏輯備份恢復MySql
- 《入門MySQL—備份與恢復》MySql
- MySQL備份與恢復——實操MySql
- 入門MySQL——備份與恢復MySql
- docker 中 MySQL 備份及恢復DockerMySql
- MySQL備份與恢復操作解析MySql
- Mysql資料備份與恢復MySql
- MySQL 定時增量備份MySql
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- RAC備份恢復之Voting備份與恢復
- mysql point in time recovery using sql_thread SQL_Thread增量恢復binlog 要點MySqlthread
- Mysql的幾種備份與恢復MySql
- 【MySQL】Xtrabackup備份及恢復指令碼MySql指令碼
- Mysql資料庫備份及恢復MySql資料庫
- MySQL8.4備份恢復快速命令MySql
- MySQL入門--備份與恢復(三)MySql
- MySQL入門--備份與恢復(一)MySql
- MySQL入門--備份與恢復(二)MySql
- MySQL 日誌管理、備份與恢復MySql
- MySQL日誌管理,備份和恢復MySql
- MySQL備份和恢復方法彙總MySql
- MySQL 透過 binlog 恢復資料MySql
- MySQL 通過 binlog 恢復資料MySql