How to regularly back up mysql using bat scripts in Windows

Source: Internet
Author: User

Not all MySQL instances run in Linux, but routine backup is also required in windows. The following is an example of automated backup using the bat script.

Rem

Rem C: The Program FilesWinRAR must be placed under the path to call the rar cli tool.

Rem

Redirect rem 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 record log

Echo "% date %" % LOG_FILE %

Rem starts backup

Mysqldump -- default-character-set = utf8-hlocalhost-uroot-R -- triggers -- single-transaction-B mydb> % BAK_FILE %

Rem compressed backup file

Rar a packet bak_file).rar % BAK_FILE %

Rem Delete source file

Del/F % BAK_FILE %

Echo "% date %" % LOG_FILE %

Echo "" "% LOG_FILE %

After the script is deployed, add the "scheduled task" project to the system.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.