{"id":809,"date":"2008-05-03T16:02:44","date_gmt":"2008-05-03T21:02:44","guid":{"rendered":"http:\/\/www.bytebot.net\/blog\/?p=809"},"modified":"2008-05-03T16:03:33","modified_gmt":"2008-05-03T21:03:33","slug":"playing-with-mysqls-online-backup","status":"publish","type":"post","link":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup","title":{"rendered":"Playing with MySQL&#8217;s Online Backup"},"content":{"rendered":"<p>Something that has excited me for a long time with upcoming features in the MySQL Server, is <strong>online backup<\/strong>. Since seeing it first being demonstrated by Chuck Bell at the Heidelberg Developers Conference in 2007, I&#8217;ve been enthralled. Now you too, can try online backup.<\/p>\n<p>If you&#8217;ve not read the Forge Wiki page about it yet, please head over to <a href=\"http:\/\/forge.mysql.com\/wiki\/OnlineBackup\">Online Backup<\/a> on the Wiki. You can grab the latest source from <a href=\"http:\/\/mysql.bkbits.net:8080\/mysql-6.0-backup\/\">mysql-6.0-backup<\/a> from <a href=\"http:\/\/mysql.bkbits.net\/\">mysql.bkbits.net<\/a>. If you&#8217;ve never built MySQL from source before, go ahead and read <a href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/10\/11\/building-mysql-from-source\">Building MySQL from source<\/a>. And you naturally need to test it once built, so I suggest making use of <a href=\"http:\/\/sourceforge.net\/projects\/mysql-sandbox\/\">MySQL Sandbox<\/a>.<\/p>\n<p><strong>NOTE: mysql-6.0-backup is the MySQL Backup Team Tree, and frequently changes and can break sometimes. This is not for production use. It can eat babies.<\/strong><\/p>\n<p>So, you&#8217;ve got BitKeeper (<tt>bkf<\/tt>) built, you&#8217;ve checked out the code, you&#8217;ve built it, and you have a binary distribution.<\/p>\n<p>Place the built version in a location that <tt>sanbox<\/tt> likes (<tt>\/opt\/mysql<\/tt> in my case). Now, run <tt>.\/express-install.pl \/opt\/mysql\/mysql-6.0.6-alpha-darwin9.2.1-i386.tar.gz<\/tt>. Once the install is completed, head over to <tt>~\/msb_6_0_6<\/tt> and run <tt>.\/use<\/tt>.<\/p>\n<p><strong>Backing up&#8230;<\/strong><\/p>\n<p>I now loaded the sakila sample database. Then, I proceeded to backup the database.<\/p>\n<pre>\r\nBACKUP DATABASE sakila TO 'sakila-backup.sql';\r\n+-----------+\r\n| backup_id |\r\n+-----------+\r\n| 1         | \r\n+-----------+\r\n1 row in set (0.37 sec)\r\n<\/pre>\n<p><tt>sakila-backup.sql<\/tt> is saved in your MySQL &#8220;data&#8221; directory, and in the case of the sandbox, its kept in your home directory.<\/p>\n<pre>du -sh ~\/msb_6_0_6\/data\/sakila-backup.sql\r\n1.9M\t\/Users\/ccharles\/msb_6_0_6\/data\/sakila-backup.sql<\/pre>\n<p>Out of curiosity, I ran file on the backup, and it was reported to be data (not ASCII English text, with very long lines):<\/p>\n<pre>file ~\/msb_6_0_6\/data\/sakila-backup.sql\r\n\/Users\/ccharles\/msb_6_0_6\/data\/sakila-backup.sql: data<\/pre>\n<p>Once you&#8217;ve done the backup, you might want to check the state:<\/p>\n<pre>SELECT * FROM mysql.online_backup WHERE backup_id = 1 \\G\r\n*************************** 1. row ***************************\r\n          backup_id: 1\r\n         process_id: 0\r\n         binlog_pos: 0\r\n        binlog_file: NULL\r\n       backup_state: complete\r\n          operation: backup\r\n          error_num: 0\r\n        num_objects: 16\r\n        total_bytes: 1654492\r\nvalidity_point_time: 2008-05-03 18:55:19\r\n         start_time: 2008-05-03 18:55:18\r\n          stop_time: 2008-05-03 18:55:19\r\nhost_or_server_name: localhost\r\n           username: msandbox\r\n        backup_file: sakila-backup.sql\r\n       user_comment:\r\n            command: BACKUP DATABASE sakila TO 'sakila-backup.sql'\r\n            engines: Default\r\n1 row in set (0.00 sec)<\/pre>\n<p><tt>online_backup<\/tt> provides statistics and metadata about a backup or restore. There is another table in the <tt>mysql<\/tt> database, that allows you to find progress information, and its called <tt>online_backup_progress<\/tt>.<\/p>\n<p>If you run <tt>SELECT * FROM mysql.online_backup_progress WHERE backup_id = 1 \\G<\/tt>, you&#8217;ll see notes changing from starting, running, validity point, running to complete.<\/p>\n<p><strong>Restoring&#8230;<\/strong><\/p>\n<p>Now, its time to restore. Note that the restore is what is known as a destructive restore (i.e. it will replace the current version of the database).<\/p>\n<pre>RESTORE FROM 'sakila-backup.sql';\r\n+-----------+\r\n| backup_id |\r\n+-----------+\r\n| 2         |\r\n+-----------+\r\n1 row in set (3.04 sec)<\/pre>\n<p>That&#8217;s it! You&#8217;ve restored your database. For posterity, here&#8217;s some statistics on the restore:<\/p>\n<pre>SELECT * FROM mysql.online_backup WHERE backup_id = 2 \\G\r\n*************************** 1. row ***************************\r\n          backup_id: 2\r\n         process_id: 0\r\n         binlog_pos: 0\r\n        binlog_file: NULL\r\n       backup_state: complete\r\n          operation: restore\r\n          error_num: 0\r\n        num_objects: 16\r\n        total_bytes: 1654492\r\nvalidity_point_time: NULL\r\n         start_time: 2008-05-03 19:01:25\r\n          stop_time: 2008-05-03 19:01:28\r\nhost_or_server_name: localhost\r\n           username: msandbox\r\n        backup_file: sakila-backup.sql\r\n       user_comment:\r\n            command: RESTORE FROM 'sakila-backup.sql'\r\n            engines: Default\r\n1 row in set (0.00 sec)<\/pre>\n<p>There you have it, <a href=\"http:\/\/forge.mysql.com\/wiki\/OnlineBackup\">MySQL 6.0&#8217;s Backup and Restore<\/a> functionality. Still in its early stages of development, but very, very cool! All these features will also be available in MySQL 6.0.5, when this gets released&#8230;<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Playing%20with%20MySQL%27s%20Online%20Backup&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2008%2F05%2F03%2Fplaying-with-mysqls-online-backup&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"ebe6e8e2af\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-809\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-809\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-809\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Something that has excited me for a long time with upcoming features in the MySQL Server, is online backup. Since seeing it first being demonstrated by Chuck Bell at the Heidelberg Developers Conference in 2007, I&#8217;ve been enthralled. Now you too, can try online backup. If you&#8217;ve not read the Forge Wiki page about it [&hellip;]<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Playing%20with%20MySQL%27s%20Online%20Backup&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2008%2F05%2F03%2Fplaying-with-mysqls-online-backup&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"ebe6e8e2af\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-809\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-809\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-809\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/03\/playing-with-mysqls-online-backup?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[23],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4vJD-d3","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":961,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/08\/26\/a-video-of-online-backup","url_meta":{"origin":809,"position":0},"title":"A video of online backup","date":"26\/8\/2008","format":false,"excerpt":"Robin just wrote a new article, titled A Quick Look at MySQL 6.0's New Backup, and I thought, that maybe you'd like to also see this in presentation\/video format... At OSCON, Giuseppe actually gave a quick talk at the Sun booth, about our online backup. He also showed how to\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1308,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2009\/02\/06\/incremental-backup-that-uses-mysql","url_meta":{"origin":809,"position":1},"title":"Incremental backup that uses MySQL","date":"6\/2\/2009","format":false,"excerpt":"A while back, Ted Ts'o asked for a incremental backup solution that used a database. It reminded me of the talk at the 2009 MySQL Conference & Expo, titled Build your own MySQL time machine. Chuck and Mats will talk about the backup and replication code, and will show off\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1638,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2010\/01\/12\/some-mysql-related-links","url_meta":{"origin":809,"position":2},"title":"Some MySQL-related links","date":"12\/1\/2010","format":false,"excerpt":"Check out how Linden Labs, creators of the popular game Second Life, upgraded their MySQL database. The MySQL they use? Straight out of Debian! Of course, now, they're running with the Percona patchset, against MySQL 5.0.84. Definitely a good read. Its good to see Lars post about contributing to the\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3491,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2019\/11\/10\/database-tab-sweep","url_meta":{"origin":809,"position":3},"title":"Database Tab Sweep","date":"10\/11\/2019","format":false,"excerpt":"I miss a proper database related newsletter for busy people. There\u2019s so much happening in the space, from tech, to licensing, and even usage. Anyway, quick tab sweep. Paul Vall\u00e9e (of Pythian fame) has been working on Tehama for sometime, and now he gets to do it full time as\u2026","rel":"","context":"In &quot;MongoDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1347,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2009\/02\/24\/on-magnolia-and-data-recovery","url_meta":{"origin":809,"position":4},"title":"On Ma.gnolia, and data recovery","date":"24\/2\/2009","format":false,"excerpt":"There's a good podcast from Chris Messina and Larry Halff, about what really happened at Ma.gnolia. If you're at all interested in what happened (i.e. how did they lose all their bookmark data), don't hesitate to watch the video. I took some quick notes: half a terabyte database file got\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":787,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/winners-for-2008-at-the-mysql-conference","url_meta":{"origin":809,"position":5},"title":"Winners for 2008 at the MySQL Conference","date":"15\/4\/2008","format":false,"excerpt":"2008 MySQL Application of the YearSocial Network - MySQL powered with over 70 million active users (Facebook)Mobile operator - Highly available LAMP platform at the heart of SMS, mobile and CRM applications (Virgin Mobile France)eCommerce site - Built caching tier using MySQL for 4 billion transactions per day (eBay)2008 MySQL\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/809"}],"collection":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/comments?post=809"}],"version-history":[{"count":0,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/809\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/media?parent=809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/categories?post=809"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/tags?post=809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}