简体   繁体   中英

MySQL point-in-time recovery

I have a system where I have binary-logging enabled and I perform a mysqldump (single-transaction, all InnoDB) nightly. If I wanted to perform a point-in-time recovery, how would I know at which point in the binary log to start rolling forward? For example.

bin-log.000001 contains all the change before, and after my dump.sql file. If I do:

mysql < dump.sql

To restore to the last full export and then roll forward to the latest point using:

mysqlbinlog bin-log.000001 | mysql

Will MySQL know the right place to start from?

So yeah, a bit more research has led me here . Just in case anyone else was wondering.

See the usage of 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).

Seems to do exactly what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM