1

i stuck on one question! the question is that i hava a large database in production environment and i have a full, incremental backup like till 2pm and aftre 1 hour i suddenly run the "drop database" command and now i want to restore that database before "drop database" statement from binary log files. And the difficulty is that how i know that from which binary log file i have to restore my data when there are so many binlog files like 100 files?

Erik Reasonable Rates Darling
46.4k14 gold badges146 silver badges542 bronze badges
asked Aug 1, 2022 at 6:41

1 Answer 1

0

You dump each binlog file and grep it until you find the file and position you're looking for.

Example: I ran 'drop schema test2' on my local instance and then checked the last binary log file. I use grep -B3 which outputs the line that matches and the 3 lines before that line.

mysqlbinlog binlog.000069 | grep -B3 'drop schema test2'
# at 43985
#220801 10:12:41 server id 1 end_log_pos 44090 CRC32 0xaf5591a1 Query thread_id=107 exec_time=0 error_code=0 Xid = 1016
SET TIMESTAMP=1659373961/*!*/;
drop schema test2

If you have 100 binary log files, you need to search them one by one. This is a tedious chore, time-consuming and boring. But this is the way to do it.

answered Aug 1, 2022 at 17:17
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.