Table of Contents Chapter 7 Backup and Recovery 7.1 Backup and Recovery Types ................................................................................................... 1612 7.2 Database Backup Methods ...................................................................................................... 1615 7.3 Example Backup and Recovery Strategy ................................................................................. 1617 7.3.1 Establishing a Backup Policy ........................................................................................ 1618 7.3.2 Using Backups for Recovery ......................................................................................... 1620 7.3.3 Backup Strategy Summary ........................................................................................... 1620 7.4 Using mysqldump for Backups ................................................................................................ 1620 7.4.1 Dumping Data in SQL Format with mysqldump .............................................................. 1621 7.4.2 Reloading SQL-Format Backups ................................................................................... 1622 7.4.3 Dumping Data in Delimited-Text Format with mysqldump ............................................... 1623 7.4.4 Reloading Delimited-Text Format Backups .................................................................... 1624 7.4.5 mysqldump Tips ........................................................................................................... 1625 7.5 Point-in-Time (Incremental) Recovery ...................................................................................... 1626 7.5.1 Point-in-Time Recovery Using Binary Log ..................................................................... 1627 7.5.2 Point-in-Time Recovery Using Event Positions ............................................................... 1628 7.6 MyISAM Table Maintenance and Crash Recovery .................................................................... 1630 7.6.1 Using myisamchk for Crash Recovery ........................................................................... 1631 7.6.2 How to Check MyISAM Tables for Errors ...................................................................... 1631 7.6.3 How to Repair MyISAM Tables ..................................................................................... 1632 7.6.4 MyISAM Table Optimization .......................................................................................... 1634 7.6.5 Setting Up a MyISAM Table Maintenance Schedule ....................................................... 1635 It is important to back up your databases so that you can recover your data and be up and running again in case problems occur, such as system crashes, hardware failures, or users deleting data by mistake. Backups are also essential as a safeguard before upgrading a MySQL installation, and they can be used to transfer a MySQL installation to another system or to set up replica servers. MySQL offers a variety of backup strategies from which you can choose the methods that best suit the requirements for your installation. This chapter discusses several backup and recovery topics with which you should be familiar: •Types of backups: Logical versus physical, full versus incremental, and so forth. •Methods for creating backups. •Recovery methods, including point-in-time recovery. •Backup scheduling, compression, and encryption. •Table maintenance, to enable recovery of corrupt tables. Additional Resources Resources related to backup or to maintaining data availability include the following: •Customers of MySQL Enterprise Edition can use the MySQL Enterprise Backup product for backups. For an overview of the MySQL Enterprise Backup product, see Section 30.2, “MySQL Enterprise Backup Overview” . •A forum dedicated to backup issues is available at https://forums.mysql.com/list.php?28. 1611