7.1 Backup and Recovery Types备份和恢复类型

This section describes the characteristics of different types of backups.本节介绍不同类型备份的特征。

Physical (Raw) Versus Logical Backups物理(原始)备份与逻辑备份

Physical backups consist of raw copies of the directories and files that store database contents. 物理备份由存储数据库内容的目录和文件的原始副本组成。This type of backup is suitable for large, important databases that need to be recovered quickly when problems occur.这种类型的备份适用于需要在出现问题时快速恢复的大型重要数据库。

Logical backups save information represented as logical database structure (CREATE DATABASE, CREATE TABLE statements) and content (INSERT statements or delimited-text files). 逻辑备份保存表示为逻辑数据库结构(CREATE DATABASECREATE TABLE语句)和内容(INSERT语句或分隔文本文件)的信息。This type of backup is suitable for smaller amounts of data where you might edit the data values or table structure, or recreate the data on a different machine architecture.这种类型的备份适用于较小数量的数据,您可以编辑数据值或表结构,或者在不同的计算机体系结构上重新创建数据。

Physical backup methods have these characteristics:物理备份方法具有以下特点:

Logical backup methods have these characteristics:逻辑备份方法具有以下特点:

Online Versus Offline Backups在线备份与离线备份

Online backups take place while the MySQL server is running so that the database information can be obtained from the server. 在线备份在MySQL服务器运行时进行,以便从服务器获取数据库信息。Offline backups take place while the server is stopped. 脱机备份在服务器停止时进行。This distinction can also be described as hot versus cold backups; a warm backup is one where the server remains running but locked against modifying data while you access database files externally.这种区别也可以描述为“热”备份与“冷”备份;“热”备份是指当您从外部访问数据库文件时,服务器仍在运行,但无法修改数据的备份。

Online backup methods have these characteristics:在线备份方法具有以下特点:

Offline backup methods have these characteristics:脱机备份方法具有以下特点:

A similar distinction between online and offline applies for recovery operations, and similar characteristics apply. 在线和离线之间的类似区别适用于恢复操作,类似的特征也适用于恢复操作。However, it is more likely for clients to be affected by online recovery than by online backup because recovery requires stronger locking. 但是,与在线备份相比,客户端更可能受到在线恢复的影响,因为恢复需要更强的锁定。During backup, clients might be able to read data while it is being backed up. 在备份期间,客户端可能能够在备份数据时读取数据。Recovery modifies data and does not just read it, so clients must be prevented from accessing data while it is being restored.恢复会修改数据,而不仅仅是读取数据,因此必须防止客户端在恢复数据时访问数据。

Local Versus Remote Backups本地备份与远程备份

A local backup is performed on the same host where the MySQL server runs, whereas a remote backup is done from a different host. 本地备份是在运行MySQL服务器的同一台主机上执行的,而远程备份是在不同的主机上执行的。For some types of backups, the backup can be initiated from a remote host even if the output is written locally on the server. host.对于某些类型的备份,即使输出在服务器上本地写入,也可以从远程主机启动备份。

Snapshot Backups快照备份

Some file system implementations enable snapshots to be taken. 一些文件系统实现允许拍摄“快照”。These provide logical copies of the file system at a given point in time, without requiring a physical copy of the entire file system. 它们在给定的时间点提供文件系统的逻辑副本,而不需要整个文件系统的物理副本。(For example, the implementation may use copy-on-write techniques so that only parts of the file system modified after the snapshot time need be copied.) (例如,该实现可以使用写时复制技术,以便只需要复制快照时间之后修改的文件系统的一部分。)MySQL itself does not provide the capability for taking file system snapshots. MySQL本身不提供获取文件系统快照的功能。It is available through third-party solutions such as Veritas, LVM, or ZFS.它可通过第三方解决方案(如Veritas、LVM或ZFS)获得。

Full Versus Incremental Backups完整备份与增量备份

A full backup includes all data managed by a MySQL server at a given point in time. 完整备份包括MySQL服务器在给定时间点管理的所有数据。An incremental backup consists of the changes made to the data during a given time span (from one point in time to another). 增量备份包括在给定的时间跨度内(从一个时间点到另一个时间点)对数据所做的更改。MySQL has different ways to perform full backups, such as those described earlier in this section. MySQL有不同的方法来执行完整备份,如本节前面所述。Incremental backups are made possible by enabling the server's binary log, which the server uses to record data changes.通过启用服务器用于记录数据更改的二进制日志,可以实现增量备份。

Full Versus Point-in-Time (Incremental) Recovery完全恢复与时间点(增量)恢复

A full recovery restores all data from a full backup. 完全恢复从完全备份中恢复所有数据。This restores the server instance to the state that it had when the backup was made. 这会将服务器实例恢复到备份时的状态。If that state is not sufficiently current, a full recovery can be followed by recovery of incremental backups made since the full backup, to bring the server to a more up-to-date state.如果该状态不是最新状态,则完全恢复之后可以恢复自完全备份以来进行的增量备份,以使服务器处于更为最新的状态。

Incremental recovery is recovery of changes made during a given time span. 增量恢复是指恢复在给定时间范围内所做的更改。This is also called point-in-time recovery because it makes a server's state current up to a given time. 这也称为时间点恢复,因为它使服务器的状态在给定时间内保持为当前状态。Point-in-time recovery is based on the binary log and typically follows a full recovery from the backup files that restores the server to its state when the backup was made. 时间点恢复基于二进制日志,通常在从备份文件进行完全恢复之后进行,该文件将服务器恢复到备份时的状态。Then the data changes written in the binary log files are applied as incremental recovery to redo data modifications and bring the server up to the desired point in time.然后,二进制日志文件中写入的数据更改将作为增量恢复应用,以重做数据修改,并使服务器达到所需的时间点。

Table Maintenance表维护

Data integrity can be compromised if tables become corrupt. 如果表损坏,数据完整性可能会受到损害。For InnoDB tables, this is not a typical issue. 对于InnoDB表,这不是一个典型的问题。For programs to check MyISAM tables and repair them if problems are found, see Section 7.6, “MyISAM Table Maintenance and Crash Recovery”.有关检查MyISAM表并在发现问题时进行修复的程序,请参阅第7.6节,“MyISAM表维护和故障恢复”

Backup Scheduling, Compression, and Encryption备份计划、压缩和加密

Backup scheduling is valuable for automating backup procedures. 备份计划对于自动化备份过程很有价值。Compression of backup output reduces space requirements, and encryption of the output provides better security against unauthorized access of backed-up data. 备份输出的压缩减少了空间需求,输出的加密提供了更好的安全性,可防止未经授权访问备份数据。MySQL itself does not provide these capabilities. MySQL本身不提供这些功能。The MySQL Enterprise Backup product can compress InnoDB backups, and compression or encryption of backup output can be achieved using file system utilities. MySQL Enterprise Backup产品可以压缩InnoDB备份,并且可以使用文件系统实用程序实现备份输出的压缩或加密。Other third-party solutions may be available.可能有其他第三方解决方案。