Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql full backup and incremental backup

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Full backup

To put it simply, back up all the databases or a library.

two。 Incremental backup

It is called incremental backup from the last full backup to the next full backup.

For mysql,binlong logs are mysql data, and a backup of binlong is a backup of mysql.

When backing up, you have to lock the table, which affects the user experience, so the frequency of backup has its own advantages and disadvantages.

When will the mysqldump backup of mysql come in handy?

When migrating or upgrading a database

When adding from the library

Artificial DDLDML statement, there is no way for the main library, all libraries will be executed, restore the backup

Disaster preparedness across computer rooms, need to be backed up to different places.

Necessary conditions for mysql data recovery

1. Open binlog and there is an incremental backup of all binlog files from the time it is complete to the time when something goes wrong.

Command to back up all:

[root@localhost] # mysqldump-uroot-p123456-F-- single-transaction-A-B | gzip > test.sql.gz

When backing up and restoring data, be sure to lock the table.

Simulate:

First, make a full backup of a library:

# mysqldump-uroot-p123456-B-- master-data=1-F xpg | gzip > xpg_$ (date +% F). Sql.gz

two。 Then use insert to insert two pieces of data into the xpg library

3. Delete the library using drop database dbname;, etc.

4. Is to communicate who did what and combine binlog logs.

5. Here's the point: to restore, first lock the table, or stop the web service to prohibit writing data to the mysql.

6. First, restore the fully backed up data, because the option-F has been specified, so the next operation will be written to the new binlog log file, and the sql statements in the following file will be extracted, of course, not the drop command, and then execute the sql command.

* it should be noted that if it is not drop but update that destroys the data, it will be complicated to solve, in order to prevent the misoperation of update: use the option when logging in to mysql.

-U: the function is to report an error if you do not use where conditional judgment when executing update. You can add mysql-U to the alias

Another way to specify the departure position and the end position

Option:-- start-position-- stop-position

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report