MYSQL database backup has many kinds (CP, tar, LVM2, mysqldump, xtarbackup) and so on, which depends on the size of your data. A table is given below
# from "Learn to back up MySQL database with various gestures"
Backup method |
Backup speed |
Recovery speed |
Ease of |
Function |
Generally used for |
Cp |
Fast |
Fast |
General, low flexibility |
Very weak |
Small amount of data backup |
Mysqldump |
Slow |
Slow |
General, can ignore the difference of storage engine |
So so |
Backup of small and medium data volumes |
Lvm2 |
Fast |
Fast |
General, support almost hot standby, fast |
So so |
Backup of small and medium data volumes |
Xtrabackup |
More quickly |
More quickly |
Implement InnoDB hot spares, storage engine requirements |
Powerful |
Larger-scale backup |
Of course, this article is only about mysqldump "official documents", other ways have the opportunity to share with you. When I use mysqldump to do backup, my way is relatively simple. is to use batch processing + timing to do.
Mysqldump backup is to put it bluntly, save the required statements.
Key Features : suitable for all MySQL engines, support Win Bei, full backup, partial backup (support InnoDB hot standby)
1. First write the shell script
Rem*******************************Start*****************************@echo offSet"Ymdhms=%Date~0,4%%Date~5,2%%Date~8,2%_%Time~0,2%%Time~3,2%%Time~6,2%"C:\myserver\mysql-5.7.Ten-Winx64\bin\mysqldump--opt-u root--password=123456 xxxdb > C:\myserver\mysql-5.7.10-winx64\db_backup\backup_%Ymdhms%.sql@echo onREM*******************************End*****************************
Description
- REM: Notes
- YMDHMS: Time
- --opt: Represents the quick,add-drop-table,add-locks,extended-insert,lock-tables that activates the mysqldump command
- : Export
- XXXDB: Database to be exported
Attention:
- Be sure to remember to change the database password to their own, otherwise the file will be empty
- If you export a table after the database and then write the table name, for example: ... xxxdb xxxtable > C:\mysql ...
Copy the shell script on top of the. bat batch script into the appropriate location.
Restore as follows:
MySQL>source C:\xxx.sql
2. Windows Scheduled Tasks
Open: Create tasks, Task Scheduler, management tools, control Panel
Conventional
Triggers (backups are performed 3 hours a day)
Save directly, then set the last step
Operation
Locate your batch file, add it in and then confirm the save, and then the list shows the task you just set up.
Attention:
The key is to not forget to open
This article does is mysqldump (full-scale backup), the next article says (incremental backup)
Mysqldump scheduled backup data (full amount)