日期:2014-05-16  浏览次数:20793 次

Windows下 MYSQL 批处理备份
@echo off
set txt1=%date:~0,4%
::当前年
set txt2=%date:~5,2%
::当前月
set txt3=%date:~8,2%
::当前日
set txt4=%time:~0,2%
::当前小时
set txt5=%time:~3,2%
::当前分钟
set txt6=%time:~6,2%
::当前秒
set date=%txt1%%txt2%%txt3%
set time=%txt4%%txt5%%txt6%

echo MySQL Database backup
echo about 10 minutes
echo don't close this window
echo it will close by itself

echo output Database
if exist %date%.sql del %date%.sql
d:\mysql\bin\mysqldump --add-drop-table -c -u root -pmima -h 127.0.0.1 shujuku > E:\databack\%date%.sql


if exist dump%date%.7z del dump%date%.7z
echo compressed,please wait
E:\databack\7za.exe a -t7z dump%date%.7z %date%.sql -mx9

echo delete temporary files
del %date%.sql

echo backup is successful!