Teach you to use bat script to back up MySQL method

Source: Internet
Author: User
Tags rar backup

There are many ways to back up MySQL, but not all MySQL can run under Linux. Windows Backup is also unavoidable. The following small compilation teaches you to use Bat script to back up the MySQL method. Next, learn to use Bat script backup MySQL Method!

Rem

REM C:Program Fileswinrar need to be placed under path to invoke the RAR CLI tool

Rem

REM jumps to the working directory

F:

CD F:dbbak

REM Settings variable: backup filename

SET Bak_file=my_dbbak_%date:~0,-4%.sql

REM Settings variable: Log file name

SET Log_file=my_dbbak.log

REM Record Log

echo "%date%"%log_file%

REM Starts doing backup

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 Delete source files

del/f%bak_file%

echo "%date%"%log_file%

echo "" "%log_file%

After you deploy the script, the rest is to add the Scheduled Tasks item 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.