How to use bat script to back up mysql regularly under Windows
This article mainly explains "how to use bat script to back up mysql regularly under Windows". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use bat scripts to back up mysql regularly under Windows"!
Not all MySQL runs under Linux, and windows also needs to do routine backups. The following is an example of using bat scripts to do automatic backups, which you can refer to.
Rem
Rem C:Program FilesWinRAR needs to be placed under path before you can call the rar cli tool
Rem
Rem jumps to the working directory
F:
Cd f:DBBAK
Rem setting variable: backup file name
SET BAK_FILE=MY_DBBAK_%date:~0,-4%.sql
Rem setting variable: log file name
SET LOG_FILE=MY_DBBAK.log
Rem logging
Echo 'date%' 'LOG_FILE%
Rem starts making backups.
Mysqldump-- default-character-set=utf8-hlocalhost-uroot-R-triggers-- single-transaction-B mydb >% BAK_FILE%
Rem compressed backup files
Rar a BAK_FILE%.rar BAK_FILE%
Rem deletes the source file
Del / F% BAK_FILE%
Echo 'date%' 'LOG_FILE%
Echo "" LOG_FILE% "
After deploying the script, all that is left is to add a "scheduled task" project to the system.
At this point, I believe you have a deeper understanding of "how to use bat scripts to back up mysql regularly under Windows". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!