{"id":2255,"date":"2018-06-11T19:53:01","date_gmt":"2018-06-11T19:53:01","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=2255"},"modified":"2018-06-11T19:53:01","modified_gmt":"2018-06-11T19:53:01","slug":"mysql-innodb-backup","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=2255","title":{"rendered":"Mysql InnoDB Backup"},"content":{"rendered":"<p>The key to safe database management is making regular backups. Depending on your data volume, number of MySQL servers, and database workload, you can use these backup techniques, alone or in combination: <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/glossary.html#glos_hot_backup\" target=\"_top\">hot backup<\/a> with MySQL Enterprise Backup; <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/glossary.html#glos_cold_backup\" target=\"_top\">cold backup<\/a> by copying files while the MySQL server is shut down; <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/glossary.html#glos_logical_backup\" target=\"_top\">logical backup<\/a> with <span class=\"command\"><strong>mysqldump<\/strong><\/span> for smaller data volumes or to record the structure of schema objects. Hot and cold backups are <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/glossary.html#glos_physical_backup\" target=\"_top\">physical backups<\/a> that copy actual data files, which can be used directly by the <span class=\"command\"><strong>mysqld<\/strong><\/span> server for faster restore.<\/p>\n<p>Using <span class=\"emphasis\"><em>MySQL Enterprise Backup<\/em><\/span> is the recommended method for backing up <code class=\"literal\">InnoDB<\/code> data.<\/p>\n<div class=\"note\">\n<div class=\"admon-title\">Note<\/div>\n<p><code class=\"literal\">InnoDB<\/code> does not support databases that are restored using third-party backup tools.<\/p>\n<\/div>\n<h2><a name=\"idm140601732838240\"><\/a>Hot Backups<\/h2>\n<p>The <span class=\"command\"><strong>mysqlbackup<\/strong><\/span> command, part of the MySQL Enterprise Backup component, lets you back up a running MySQL instance, including <code class=\"literal\">InnoDB<\/code> tables, with minimal disruption to operations while producing a consistent snapshot of the database. When <span class=\"command\"><strong>mysqlbackup<\/strong><\/span> is copying <code class=\"literal\">InnoDB<\/code> tables, reads and writes to <code class=\"literal\">InnoDB<\/code> can continue. MySQL Enterprise Backup can also create compressed backup files, and back up subsets of tables and databases. In conjunction with the MySQL binary log, users can perform point-in-time recovery. MySQL Enterprise Backup is part of the MySQL Enterprise subscription. For more details, see <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/mysql-enterprise-backup.html\" target=\"_top\">MySQL Enterprise Backup Overview<\/a>.<\/p>\n<h2><a name=\"idm140601732832784\"><\/a>Cold Backups<\/h2>\n<p>If you can shut down the MySQL server, you can make a physical backup that consists of all files used by <code class=\"literal\">InnoDB<\/code> to manage its tables. Use the following procedure:<\/p>\n<div class=\"orderedlist\">\n<ol class=\"orderedlist\" type=\"1\">\n<li class=\"listitem\">Perform a <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/glossary.html#glos_slow_shutdown\" target=\"_top\">slow shutdown<\/a> of the MySQL server and make sure that it stops without errors.<\/li>\n<li class=\"listitem\">Copy all <code class=\"literal\">InnoDB<\/code> data files (<code class=\"filename\">ibdata<\/code> files and <code class=\"filename\">.ibd<\/code> files) into a safe place.<\/li>\n<li class=\"listitem\">Copy all the <code class=\"filename\">.frm<\/code> files for <code class=\"literal\">InnoDB<\/code> tables to a safe place.<\/li>\n<li class=\"listitem\">Copy all <code class=\"literal\">InnoDB<\/code> log files (<code class=\"filename\">ib_logfile<\/code> files) to a safe place.<\/li>\n<li class=\"listitem\">Copy your <code class=\"filename\">my.cnf<\/code> configuration file or files to a safe place.<\/li>\n<\/ol>\n<\/div>\n<h2><a name=\"idm140601732820352\"><\/a>Logical Backups Using mysqldump<\/h2>\n<p>In addition to physical backups, it is recommended that you regularly create logical backups by dumping your tables using <span class=\"command\"><strong>mysqldump<\/strong><\/span>. A binary file might be corrupted without you noticing it. Dumped tables are stored into text files that are human-readable, so spotting table corruption becomes easier. Also, because the format is simpler, the chance for serious data corruption is smaller. <span class=\"command\"><strong>mysqldump<\/strong><\/span> also has a <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/mysqldump.html#option_mysqldump_single-transaction\" target=\"_top\"><code class=\"option\">--single-transaction<\/code><\/a> option for making a consistent snapshot without locking out other clients. See <a class=\"xref\" title=\"1.3.1\u00a0Establishing a Backup Policy\" href=\"https:\/\/dev.mysql.com\/doc\/mysql-backup-excerpt\/5.5\/en\/backup-policy.html\">Section\u00a01.3.1, \u201cEstablishing a Backup Policy\u201d<\/a>.<\/p>\n<p>Replication works with <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/innodb-storage-engine.html\" target=\"_top\"><code class=\"literal\">InnoDB<\/code><\/a> tables, so you can use MySQL replication capabilities to keep a copy of your database at database sites requiring high availability. See <a class=\"ulink\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/innodb-and-mysql-replication.html\" target=\"_top\">InnoDB and MySQL Replication<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>https:\/\/dev.mysql.com\/doc\/mysql-backup-excerpt\/5.5\/en\/innodb-backup.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The key to safe database management is making regular backups. Depending on your data volume, number of MySQL servers, and database workload, you can use these backup techniques, alone or in combination: hot backup with MySQL Enterprise Backup; cold backup by copying files while the MySQL server is shut down; logical backup with mysqldump for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[172],"class_list":["post-2255","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-mysql","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2255"}],"version-history":[{"count":1,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2255\/revisions"}],"predecessor-version":[{"id":2256,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2255\/revisions\/2256"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2255"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}