How to back up mysql using bat script

Source: Internet
Author: User

There are actually many methods to back up mysql, but not all mysql can run in linux. Backup in windows is also indispensable. The following section will teach you how to back up mysql using the bat script. Let's take a look at how to back up mysql 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.

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.