1 Build Your Own MySQL Time Machine Chuck Bell, PhD Mats Kindahl, PhD Replication and Backup Team Sun Microsystems 1
2 About the Speakers Chuck Bell, PhD > Working on Backup > (recovering) Windows Developer > Mats Kindahl, PhD > Replication Expert and Lead Developer >
3 Topics Point-in-time Recovery What is the MySQL Time Machine? Problem Statement Technology How do you use it? Demonstration A look under the hood Resources
Point-in-time recovery Backup image + Binlog files = Recovery image Saved recovery images can be archived Active recovery image is still growing Backup :00: :00:00 Saved recovery image Active recovery image RI-1 RI-2
Backing up Take the backup Backup :00: :00:00 Active recovery image RI-1 RI-2
Backing up Note binlog position for backup image Backup :00: :00:00 Active recovery image RI-1 RI-2
Backing up Save away old backup image Backup :00: :00:00 Active recovery image RI-1 RI-2
Backing up Save away binlog positions for old image Backup :00: :00:00 Active recovery image RI-1 RI-2
Backing up Save away (or keep track of) binlog files Backup :00: :00:00 Active recovery image RI-1 RI-2
Backing up This is now your old recovery image Backup :00: :00:00 Active recovery image RI-1 RI-2 Saved
Backing up This is now your new active recovery image Backup :00: :00:00 Active recovery image RI-1 RI-2 Saved Backup Active recovery image
Recovery Backup :00: :00:00 Saved recovery image RI-1 RI-2 Backup Active recovery image Date
Recovery Backup :00: :00:00 Saved recovery image RI-1 RI-2 Backup Active recovery image Date <End Start< Don't forget to stop slave!
Recovery Backup :00:00 RI-1 RI-2 Date <End Start<
Recovery Backup :00:00 RI-1 RI-2 Date <End Start< Play
Recovery Backup :00:00 RI-1 RI-2 Date <End Start< Play Don't forget to do the same on the slave!
Recovery Backup :00:00 RI-1 RI-2 Date <End Start< Play Now, do the same thing with the slave and ensure that they are in sync!
Recovery Backup :00:00 RI-1 RI-2 Date <End Start< Play Remember that you go back in time, but binlog still grows! “Old“ events go here!
19 There must be a better way.... The MySQL Time Machine!
20 What is the MySQL Time Machine? Web-based utility for managing remote backup and restore. Key Features > Automated backup > Backup multiple databases > Restore by backup point – the point in time when a backup is run on the time machine > Restore by date – arbitrary datetime > Easy to use
21 Problem Statement Why can't someone build a fully automated backup solution that you can just turn on and forget? Automated backup and restore Simplified interface No knowledge of replication needed No complex installation** or configuration Does not require dedicated, expensive hardware
22 Technology Built using MySQL 6.0 PHP Perl Apache Replication MySQL Backup – new in 6.0! Time Machine runs on Linux > Currently connects to Windows or Linux systems
23 Architecture The time machine uses at most three connections to the database server you want to backup. > MySQL replication > MySQL client > SSH/SCP | MySQL |--- replication ---> | MySQL | | Client | | Server | | Time | | Web | | |< | Machine | | Apache | | Browser | | | | | | | PHP | | | | |< | | | | | | | | | | | | | | >| MySQL | | | Client | | | | | | | >| SSH/SCP | | shell | | |
24 How Replication is Used Master/Slave Row-based Binary Logging Point-in-time Recovery
25 How Do You Use the Time Machine? Administrator's Console Setup and Configuration Connecting the Time Machine Performing a Restore by Backup Point Performing a Restore by Date Administration Functions
26 Administrator's Console Main Screen Initiate Restores Monitor Status
27 Status DB - The database server to which the time machine is connected. TM - The MySQL instance on the time machine. Tx - Connection status to the time machine's MySQL instance. Rx - Status of communication (replication) from the database server.
28 Setup and Configuration Connect Control Time Machine Disconnect and reconnect Set automated backup frequency
29 Connecting the Time Machine Results page Shows each step Displays data for diagnostics
30 Examining Backup Points Detailed Report Summary Report Can be helpful to see what is included in each backup point
31 Performing Restore by Backup Point Select backup point Click Restore to Backup Point Automated How cool is that?
32 Restore Results
33 Performing Restore by Date Select datetime Click Restore to Datetime Automated How cool is that?
34 Restore Results
35 Maintenance Operations Connect Disconnect and Reconnect Save Configuration Start Stop Reset
36 Live Demonstration
37 A Look Under The Hood Connection Sequence Restore by Backup Point Restore by Date
38 Connection Sequence Stop replication Backup data on database server Record database server's binlog information Copy file to time machine Restore data on time machine Restart replication Sync slave with master on time machine Perform initial backup Launch automated backup cron job
39 Restore by Backup Point Stop replication Flush logs on time machine Copy file to database server Run restore on database server Record database server's binlog information Run restore on time machine Start replication
40 Restore by Date Determine nearest backup point and binary log on time machine Stop replication Flush logs on time machine Copy file to database server Run restore on database server Use mysqlbinlog to replay binary log on database server Record database server's binlog information Run restore on time machine Use mysqlbinlog to replay binary log on database server Start replication
41 Resources Books > Expert MySQL > Attribute Level Versioning
42 Related Conference Sessions The Future of Replication > 04/22/ :55am - 12:40pm Room: Ballroom G Replication Tricks & Tips > 04/23/ :50am - 11:50am Room: Ballroom F Backup and Replication Integration Techniques > 04/23/2009 2:00pm - 2:45pm Room: Ballroom F
43 Questions?