2013-10-31 68 views
0

我有一個系統,我啓用了二進制日誌記錄,並且每夜執行一次mysqldump(單一事務,所有InnoDB)。如果我想執行時間點恢復,我怎麼會知道二進制日誌中的哪一點開始向前滾動?例如。MySQL時間點恢復

bin-log.000001包含我的dump.sql文件之前和之後的所有更改。如果我做的:

mysql < dump.sql 

要恢復到上一次完全導出,然後使用向前滾動到最新:

mysqlbinlog bin-log.000001 | mysql 

將MySQL的瞭解,從正確的開端?

回答

1

所以是的,多一點研究導致我here。以防萬一其他人想知道。

+0

也許更好地閱讀此:http://dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html – 2013-10-31 13:19:16

+0

這是那個文件,讓我問這個問題!我遇到的問題是知道什麼時候開始前進。使用--single-transaction --master_data = 2和--flush-logs使這一切成爲可能。 – dwjv

0

見mysqlbinlog可以的用法:

--stop-datetime=name 
         Stop reading the binlog at first event having a datetime 
         equal or posterior to the argument; the argument must be 
         a date and time in the local time zone, in any format 
         accepted by the MySQL server for DATETIME and TIMESTAMP 
         types, for example: 2004-12-25 11:25:56 (you should 
         probably use quotes for your shell to set it properly). 

似乎做你想要什麼。

+0

這將是我會嘗試的。這對我來說還不夠完美。這個數據庫上有數百次寫入。我將使用mysqlbinlog --start-position = <轉儲文件中的數字>。 – dwjv

+0

@dwjv對不起,你想從哪裏開始,而不是在哪裏結束。是的,絕對使用mysqldump的'--flush-logs'選項。然後,您可以簡單地選擇開始使用哪個二進制日誌文件,而不是單個事務。 「時間點」術語讓我感到困惑,我想...... – 2013-10-31 15:31:08