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). 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:
The backup consists of exact copies of database directories and files. Typically this is a copy of all or part of the MySQL data directory.
Physical backup methods are faster than logical because they involve only file copying without conversion.
Output is more compact than for logical backup.
Because backup speed and compactness are important for busy, important databases, the MySQL Enterprise Backup product performs physical backups. For an overview of the MySQL Enterprise Backup product, see MySQL Enterprise Backup Overview.
Backup and restore granularity ranges from the level of the entire data directory down to the level of individual files. This may or may not provide for table-level granularity, depending on storage engine. For example,
InnoDB
tables can each be in a separate file, or share file storage with otherInnoDB
tables; eachMyISAM
table corresponds uniquely to a set of files.In addition to databases, the backup can include any related files such as log or configuration files.
Data from
MEMORY
tables is tricky to back up this way because their contents are not stored on disk. (The MySQL Enterprise Backup product has a feature where you can retrieve data fromMEMORY
tables during a backup.)Backups are portable only to other machines that have identical or similar hardware characteristics.
Backups can be performed while the MySQL server is not running. If the server is running, it is necessary to perform appropriate locking so that the server does not change database contents during the backup. MySQL Enterprise Backup does this locking automatically for tables that require it.
Physical backup tools include the mysqlbackup of MySQL Enterprise Backup for
InnoDB
or any other tables, or file system-level commands (such as cp, scp, tar, rsync) forMyISAM
tables.For restore:
MySQL Enterprise Backup restores
InnoDB
and other tables that it backed up.ndb_restore restores
NDB
tables.Files copied at the file system level can be copied back to their original locations with file system commands.
Logical backup methods have these characteristics:
The backup is done by querying the MySQL server to obtain database structure and content information.
Backup is slower than physical methods because the server must access database information and convert it to logical format. If the output is written on the client side, the server must also send it to the backup program.
Output is larger than for physical backup, particularly when saved in text format.
Backup and restore granularity is available at the server level (all databases), database level (all tables in a particular database), or table level. This is true regardless of storage engine.
The backup does not include log or configuration files, or other database-related files that are not part of databases.
Backups stored in logical format are machine independent and highly portable.
Logical backups are performed with the MySQL server running. The server is not taken offline.
Logical backup tools include the mysqldump program and the
SELECT ... INTO OUTFILE
statement. These work for any storage engine, evenMEMORY
.To restore logical backups, SQL-format dump files can be processed using the mysql client. To load delimited-text files, use the
LOAD DATA
statement or the mysqlimport client.
No comments:
Post a Comment
If you have any doubt or question, please contact us.