Windows Server MySQL incremental backup batch (database)

Source: Internet
Author: User


Method One

Using mysqldump

The code is as follows Copy Code

@echo off

Set path=c:/"program Files"/winrar;%path%
Set mysqlpath=c:/"program Files"/mysql/"MySQL Server 5.0"
Set Bakpath=e:/mysql_bak
Set Username=root
Set password=1234567890

REM Please be careful to choose the backup mode, shielding other unwanted (front plus REM)
REM Backup using Mysqldump method
mkdir%bakpath%/data
%mysqlpath%/bin/mysqladmin-u%username%-p%password% Flush-logs
xcopy/e/c/h/y%mysqlpath%/data/mysql-bin.*%bakpath%/data
RAR A-ag%bakpath%/diff/%bakpath%/data/mysql-bin.*
RMDIR/S/q%bakpath%/data/

@echo%date%%time% dincremental bakup finish >> C:/mysqlbakup.log

Method Two,


Using Batch Xcopy

Function: Automatically backs up the database and creates a backup folder by date.

. The code is as follows:

The code is as follows Copy Code

@echo off
Echo Performs a backup task
ECHO is stopping the database ...
Echo is stopping the Web site database ...
net stop MySQL
Echo performs backup database
xcopy "D:/mysql/data/*.*" d:/mysqlbak/webbak%date:~0,10%//e/y/C
net start MySQL
Echo is starting the Web site database ...
Echo Quits backup task
Echo.
Exit

Dismantling:

Stop Database command

. The code is as follows:

net stop MySQL

Copy database files
d:/mysql/data/for database storage directory
D:/mysqlbak/webbak Backup directory for database
%date:~0,10% Create a directory for the current backup date

. The code is as follows:

xcopy "D:/mysql/data/*.*" d:/mysqlbak/webbak%date:~0,10%//e/y/C

Start the database

. The code is as follows:

net start MySQL


Enter the control Panel, open the Scheduled task, and double-click Add Scheduled task. In the Scheduled Task Wizard, locate the cmd file just now, and then specify a run-time and run-time account password for this task.

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.