Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to simply restore a single schema and bring it to a point in time (Say three hours ago) without bringing the entire database back?

I can think of a lengthy method of backing up each schema individually at present time, bringing the database back three hours and restoring all other schemas (except for the one you want to roll back) back to present time.

Is there any other method? Or am I not understanding binary logs correctly?

share|improve this question
up vote 3 down vote accepted

You can extract the SQL from a specific schema with the

Use mysqlbinlog utility against all binary logs that have the data and time ranges. You will have to name the database you are extracting:

For example, suppose you have the following scenario

  • You have these binary logs
    • mysql-bin.000019
    • mysql-bin.000020
    • mysql-bin.000021
    • mysql-bin.000022
    • Binary Logs span from 2013-01-30 09:30:00 to 2013-02-04 12:00:00
  • You have a full backup from 2013-02-03 00:00:00 (mysqldata-20130203.sql)
  • You want to restore MyProdDB from 02/03/13 at 2:45 PM 2013-02-03 14:45:00

STEP 01) Get all DB Changes from the Binary Logs

BEG_DT="2013-02-03 00:00:00"
END_DT="2013-02-03 14:45:00"
BINLOGS="mysql-bin.000019 mysql-bin.000020 mysql-bin.000021 mysql-bin.000022"
mysqlbinlog -d ${DB} --start-datetime="${BEG_DT}" --stop-datetime="${END_DT}" ${BINLOGS} > mysqldata-delta.sql

STEP 02) Load Data into Staging Database called MyProdDBStaging

mysql -u... -p... -DMyProdDBStaging < mysqldata-20130203.sql

STEP 03) Load Delta into Staging Database called MyProdDBStaging

mysql -u... -p... -DMyProdDBStaging < mysqldata-delta.sql

Now, the tagret database will be the point and time instance for MyProdDB at 2:45 PM on Feb 3, 2013.

Give it a Try !!!

share|improve this answer
Rolando, you're a MySQL machine :) – Phil Feb 4 '13 at 19:04
Awesome! You're the man. Time to go practice this. – Michael Capobianco Feb 4 '13 at 19:09
Tested and confirmed. Thanks again! – Michael Capobianco Feb 5 '13 at 18:10
This implemented for cPanel would be a wonderful solution! – Jose Nobile 8 hours ago

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.