search
HomeDatabaseMysql TutorialDetailed explanation of how MySQ implements data backup

This article will introduce to you what data backup is in MySQ and let you understand the method of data backup in MySQ. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

MySQL Backup Overview

Question: What is the difference between backup and redundancy?

  • Backup: It can prevent data loss due to mechanical failure and human operations, such as saving database files in other places.

  • Redundancy: There are multiple redundant copies of data, but it is not equivalent to backup. It can only prevent data loss caused by mechanical failure, such as master-standby mode, database cluster.

What is backup?

databases Binlog my.cnf /data/xxx (data directory)

Back up the database, log files, and configuration files. Try to save all the files in the data directory Backup.

Factors that must be considered during the backup process:

  • 1. A detailed backup plan (backup frequency, time point, cycle) must be developed (according to Based on the current business situation, you need to consider the backup time and the size of the backup data. If the amount of data is too large, use disaster redundancy).

  • 2. Backup data should be stored locally in a non-database location, and multiple copies are recommended

  • 3. Data recovery drills must be done (Every once in a while, the backed-up data is simulated and restored in the test environment to ensure that the data can be restored in time when a data disaster occurs.) (To ensure the availability of data) After the backup is completed, conduct a power outage simulation drill. Test whether the database can be started normally and whether the data can be restored normally.

  • 4. Choose the correct backup tool according to the occasion and characteristics of data application.

  • 5. Data consistency.

  • 6. Data availability.

Backup type

##Logical backup

Logical backup is to perform backup without stopping business.

What is backed up is the SQL statements (DDL DML DCL) executed by operations such as table creation, database creation, and insertion. It is suitable for small and medium-sized databases and has relatively low efficiency.

(Generally performed under the premise that the database provides normal services); such as: mysqldump, mydumper, into outfile (table export and import), etc.

Physical backup

Directly copy database files, suitable for large database environments, not restricted by storage engines, but cannot be restored to different MySQL versions.

(Generally, backup is performed when the database is completely shut down or cannot complete normal service provision); such as: tar, cp, xtrabackup, lvm snapshot, etc.

Online hot backup

Online hot backup: AB replication (online real-time) (referring to data redundancy)

M-S

M-Sn

M-S1-S2

M-M-Sn

Backup Tool

##Community Edition Installation Package The backup tool in

mysqldump

## is included in both Enterprise and Community editions
  • Essentially use SQL statements to describe the database and data and export
  • Lock the table in the MYISAM engine and lock the rows in the Innodb engine
  • Not recommended when the amount of data is large
  • mysqlhotcopy

Both the Enterprise Edition and Community Edition include
  • A script written in perl, which essentially uses a lock table statement to copy data
  • Only supports the MYISAM data engine
Backup tool in the enterprise version installation package

mysqlbackup

Online Backup
  • Incremental backup
  • Partial backup
  • Consistency at a specific time Status backup
Third-party backup tools

##XtraBackup and innobackupex

Xtrabackup is a tool for data backup of InnoDB. It supports online hot backup (backup does not affect data reading and writing). It is a good substitute for the commercial backup tool InnoDB Hotbackup. Xtrabackup has two The main tools: xtrabackup, innobackupex

xtrabackup can only back up InnoDB and XtraDB data tables. It cannot back up myisam type tables, nor can it back up the data table structure.

  • innobackupex is a perl script that encapsulates Xtrabackup, so it can back up the storage engines of innodb and myisam at the same time, but you need to add a read lock when processing myisam

  • mydumper

mydumper multi-threaded backup toolhttps://launchpad.net/mydumper/mydumper-0.9.1.tar.gz

Backup method

完全备份

增量备份

 

差异备份

差异增量备份

 

 • Sunday
An incremental level 0 backup backs up all blocks that have ever been in use in this database.

• Monday through Saturday
On each day from Monday through Saturday, a differential incremental level 1 backup backs up all blocks that have changed since the most recent incremental backup at level 1 or 0. The Monday backup copies blocks changed since Sunday level 0 backup, the Tuesday backup copies blocks changed since the Monday level 1 backup, and so forth.

累计增量备份

• Sunday
An incremental level 0 backup backs up all blocks that have ever been in use in this database.

• Monday - Saturday
A cumulative incremental level 1 backup copies all blocks changed since the most recent level 0 backup. Because the most recent level 0 backup was created on Sunday, the level 1 backup on each day Monday through Saturday backs up all blocks changed since the Sunday backup.

需要掌握的备份方法:

逻辑数据的导入导出(into outfile)mysqldump、mysqlhotcopy、xtrabackup和innobackupex
lvm-snapshot、mysqlbackup

总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。更多相关教程请访问mysql数据库图文教程 MySQL视频教程bootstrap视频教程

The above is the detailed content of Detailed explanation of how MySQ implements data backup. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:博客园. If there is any infringement, please contact admin@php.cn delete
How to identify and optimize slow queries in MySQL? (slow query log, performance_schema)How to identify and optimize slow queries in MySQL? (slow query log, performance_schema)Apr 10, 2025 am 09:36 AM

To optimize MySQL slow query, slowquerylog and performance_schema need to be used: 1. Enable slowquerylog and set thresholds to record slow query; 2. Use performance_schema to analyze query execution details, find out performance bottlenecks and optimize.

MySQL and SQL: Essential Skills for DevelopersMySQL and SQL: Essential Skills for DevelopersApr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

Describe MySQL asynchronous master-slave replication process.Describe MySQL asynchronous master-slave replication process.Apr 10, 2025 am 09:30 AM

MySQL asynchronous master-slave replication enables data synchronization through binlog, improving read performance and high availability. 1) The master server record changes to binlog; 2) The slave server reads binlog through I/O threads; 3) The server SQL thread applies binlog to synchronize data.

MySQL: Simple Concepts for Easy LearningMySQL: Simple Concepts for Easy LearningApr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL: A User-Friendly Introduction to DatabasesMySQL: A User-Friendly Introduction to DatabasesApr 10, 2025 am 09:27 AM

The installation and basic operations of MySQL include: 1. Download and install MySQL, set the root user password; 2. Use SQL commands to create databases and tables, such as CREATEDATABASE and CREATETABLE; 3. Execute CRUD operations, use INSERT, SELECT, UPDATE, DELETE commands; 4. Create indexes and stored procedures to optimize performance and implement complex logic. With these steps, you can build and manage MySQL databases from scratch.

How does the InnoDB Buffer Pool work and why is it crucial for performance?How does the InnoDB Buffer Pool work and why is it crucial for performance?Apr 09, 2025 am 12:12 AM

InnoDBBufferPool improves the performance of MySQL databases by loading data and index pages into memory. 1) The data page is loaded into the BufferPool to reduce disk I/O. 2) Dirty pages are marked and refreshed to disk regularly. 3) LRU algorithm management data page elimination. 4) The read-out mechanism loads the possible data pages in advance.

MySQL: The Ease of Data Management for BeginnersMySQL: The Ease of Data Management for BeginnersApr 09, 2025 am 12:07 AM

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

When might a full table scan be faster than using an index in MySQL?When might a full table scan be faster than using an index in MySQL?Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use