Dump is performed at every day to back up the corresponding database, and binlog files of the corresponding database are updated.
If a database error is found, you only need to recover the previous dump backup and then restore the binlog file of the current day.
Example:
Run the following command at every day:
Copy codeThe Code is as follows:
Mysqldump database -- flush-logs-uroot-p -- opt> database_20020601. SQL
Executed according to the date rule.
If you want to restore the database to this morning, then:
1. Complete backup of the entire database
Copy codeThe Code is as follows:
Cd/var/lib/mysql
Mysqldump-uroot-p123456 mydata> mydata. bak
2. Delete the database backed up
Copy codeThe Code is as follows:
Rm-rf mydata
3. Recover with dump
Copy codeThe Code is as follows:
Mysql-uroot-p123456
Mysql database-uroot-p123456 <database_20020601. SQL
4. Use binlog for time-based recovery
Copy codeThe Code is as follows:
Mysqlbinlog -- stop-date = "10:18:49"/var/lib/mysql/mysql-bin.000006 | mysql-uroot-p123456
Note:
1. It is best to save the dump backup and binlog backup in remote-remote backup.
2. mysql master-slave replication.