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.