Home Database Mysql Tutorial Detailed explanation of how MySQ implements data backup

Detailed explanation of how MySQ implements data backup

Oct 17, 2018 pm 05:42 PM
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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ThinkPHP6 data backup and recovery: ensuring data security ThinkPHP6 data backup and recovery: ensuring data security Aug 13, 2023 am 08:28 AM

ThinkPHP6 data backup and recovery: ensuring data security With the rapid development of the Internet, data has become an extremely important asset. Therefore, the security of data is of great concern. In web application development, data backup and recovery are an important part of ensuring data security. In this article, we will introduce how to use the ThinkPHP6 framework for data backup and recovery to ensure data security. 1. Data backup Data backup refers to copying or storing the data in the database in some way. This way even if the data

How to use PHP to implement website backup function How to use PHP to implement website backup function Jun 27, 2023 pm 01:32 PM

Backup is a very important task during website operation. If there is data loss or loss on the website, backup can facilitate the restoration of the website. PHP is a commonly used server-side programming language. The backup function of the website can be implemented by writing PHP scripts. This article will introduce how to use PHP to implement website backup function. 1. Types of backup files When backing up a website, you need to back up the database and website files. Usually website files include static files, program files, pictures and uploaded attachments, etc., while the database contains all the information of the website.

Data backup and restoration of PHP applications through Docker Compose, Nginx and MariaDB Data backup and restoration of PHP applications through Docker Compose, Nginx and MariaDB Oct 12, 2023 am 11:14 AM

Data backup and restoration of PHP applications through DockerCompose, Nginx and MariaDB. With the rapid development of cloud computing and containerization technology, more and more applications choose to use Docker to deploy and run. In the Docker ecosystem, DockerCompose is a very popular tool that can define and manage multiple containers through a single configuration file. This article will introduce how to use DockerCompose, Ng

Data backup in PHP Data backup in PHP May 24, 2023 am 08:01 AM

In the process of web development, data storage and backup are undoubtedly a very important part. In case of data loss or recovery needs, backup is very necessary. For PHP, an open source back-end language, there are also many options for data backup. Let’s take a closer look at data backup in PHP. 1. Database backup 1.1 MYSQLdump tool MYSQLdump is a command line tool for backing up MYSQL databases. It copies the entire database or database by executing SQL statements.

How to use Java to write the data backup function of CMS system How to use Java to write the data backup function of CMS system Aug 04, 2023 pm 11:22 PM

How to use Java to write the data backup function of a CMS system. In a content management system (ContentManagementSystem, CMS), data backup is a very important and essential function. Through data backup, we can ensure that the data in the system can be restored in time in the event of damage, loss or incorrect operation, thereby ensuring the stability and reliability of the system. This article will introduce how to use Java to write the data backup function of the CMS system and provide relevant code examples.

Implement data backup and recovery strategies using PHP and SQLite Implement data backup and recovery strategies using PHP and SQLite Jul 28, 2023 pm 12:21 PM

Using PHP and SQLite to implement data backup and recovery strategies Backup and recovery is a very important aspect of database management, which can protect our data from accidental damage or loss. This article will introduce how to use PHP and SQLite to implement data backup and recovery strategies, helping us better manage and protect the data in the database. First, we need to create a database using SQLite and establish some test data for subsequent operations. Here's a simple example: <?php

Data compression backup technology in MySQL Data compression backup technology in MySQL Jun 15, 2023 pm 05:23 PM

As the amount of data continues to increase, database backup becomes more and more difficult. Backup not only requires data integrity and consistency, but also requires backup speed and backup file size to meet actual needs. Data compression backup technology emerged as the times require and has become one of the indispensable technical means for database backup. MySQL is currently one of the most popular relational databases, and its officially provided backup tool mysqldump cannot meet the needs of compressed backup. Therefore, this article will introduce the use of compression command on Linux system ta

How to deal with data backup consistency issues in C++ big data development? How to deal with data backup consistency issues in C++ big data development? Aug 26, 2023 pm 11:15 PM

How to deal with the data backup consistency problem in C++ big data development? In C++ big data development, data backup is a very important part. In order to ensure the consistency of data backup, we need to take a series of measures to solve this problem. This article will discuss how to deal with data backup consistency issues in C++ big data development and provide corresponding code examples. Using transactions for data backup Transactions are a mechanism to ensure the consistency of data operations. In C++, we can use the transaction concept in the database to implement data backup.

See all articles