3 Steps to teach you a key automatic backup MySQL database method

Source: Internet
Author: User
Keywords MySQL teach you

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Backup MySQL has been a headache for many friends, especially by the time period of backup, today I will use the method of graphics and text tutorial to teach you how to a key daily backup MySQL database files.

1. First set up batch file, save the following code as a. bat file, preferably in English. Note the following path to the author's own database, for example, the database installed under the D disk under Mysql\mysql, backup location in F:\beifen, the following code is the date.

@echo off

Color 0D

MODE con:cols=71 lines=25

Title MySQL database automatic backup script (Task Scheduler)--script Author: http://www.***.com

Set sou_dir= "D:\mysql\Mysql\data"

Set obj_dir=f:\beifen\%date:~0,10%

net stop MySQL

MD%obj_dir%

xcopy/e y%sou_dir%%obj_dir%

net start MySQL

@echo off&setlocal enabledelayedexpansion

call:d,30

Echo. 30 days ago Date:%d%

Echo. Delete 30 days ago Backup ...

If exist F:\beifen\%D% rd/s/q F:\beifen\%D%

Echo Automatic backup complete, the program will automatically exit ...

Ping-n 2 127.0.0>nul

Exit

:D

for/f "Tokens=1-3 delims=-:/ '%%a in ('%date% ') do (

Set Y=%%a&set M=%%b&set d=%%c

If "! m:~0,1! " = = "0" Set m=! m:~1!

If "! d:~0,1! " = = "0" Set d=! d:~1!

)

set/a d-=%1

If%d% GTR 0 goto:y

: M

set/a m-=1

if! M!==0 set/a y-=1,m=12

set/a "t=^! (M-2) "," R= (^! ( y%%4) &^!^! (y%%100) | ^! (y%%400) "," c=^! (M-4) |^! (M-6) |^! (M-9) |^! (M-11) "," d=t* (28+r) +c*30+ (^! t&^! C)

*31+d "

If%d% Leq 0 goto:m

: Y

Set M=0%m%&set D=0%d%&set d=%y%-! M:~-2!-! d:~-2!

2, set up a scheduled task, you can daily or three days, or even longer time backup, backup when the MySQL automatically stop, after the backup is completed, MySQL will automatically start. Open the Control Panel---Double-click the Task schedule and follow the prompts to select it, as shown in the following illustration:

  

3, we can set the daily, weekly or other date to backup the MySQL database regularly. The author of the experiment, fully meet our daily MySQL database backup work needs.

  

This article original from the road rice net http://www.45fan.com, reprint needs to indicate the source!

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.