MySQL database backup script under Windows (i)

Source: Internet
Author: User

Description

MySQL Database installation directory: C:\Program files\mysql\mysql Server 5.0

MySQL Database storage directory: C:\Program files\mysql\mysql Server 5.0\data

MySQL Database backup directory: D:\MySQLdata_Bak

To achieve the purpose: backup the MySQL database in the directory to the D:\MySQLdata_Bak directory, stored by date,

And keep only the last 7 days of data

For example:

D:\MySQLdata_Bak\mysql\20120404\mysql_bak.sql

D:\MySQLdata_Bak\mysql\20120405\mysql_bak.sql

1, save the following file as: Mysql_bak.bat in the D:\MySQLdata_Bak\ directory, such as: D:\MySQLdata_Bak\mysql_bak.bat

@echo offecho.echo MySQL Database backup script by Osyunwei.comecho *****************************echo.echo backup date:%date%echo backup time:%time %echo.echo *****************************set " YMD=%DATE:~,4%%DATE:~5,2%%DATE:~8,2%"MD "D:\MySQLdata_Bak\mysql\%Ymd%"" C:\Program files"\mysql\" MySQL Server 5.0"\bin\mysqldump-uroot-p123456 mysql--default-character-set=utf8--opt-q-R--skip-lock-tabl Es > d:\mysqldata_bak\mysql\%ymd%\mysql_bak.sqlecho.forfiles/p D:\MySQLdata_Bak\mysql\/s/m * */d-7/"cmd/c de L @file "echo MySQL database backup complete echo.echo.

2. Open in Windows, start-Settings-Control Panel-Task Scheduler, add the above batch file to the task schedule, set the time of day to execute.

System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

Reprint: http://www.osyunwei.com/archives/3419.html

MySQL database backup script under Windows (i)

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.