echo Off & setlocal enableextensions
::----------Configuration Items----------
:: Backup placement path, plus
Set Backup_path=d:\backup
:: Database name to back up, multiple spaces separated
Set databases=1688 ABC Ceshi
:: MySQL User Name
Set Username=root
:: MySQL Password
Set Password=root
:: MySQL Bin directory, plus
:: If you can use dump directly (add the MySQL Bin directory to the environment variable at installation), leave this blank
Set mysql=d:\progra~1\phpstudy\mysql\bin\
:: WinRAR with command-line tools executable path, long file name note in Dos long file name writing method
Set Winrar=d:\progra~1\winrar\rar.exe
::----------Do not modify the following----------
Set year=%date:~0,4%
Set month=%date:~5,2%
Set day=%date:~8,2%
:: If the input time in DOS to return is not 24-hour system (no 0 fill), please modify this here
Set hour=%time:~0,2%
Set minute=%time:~3,2%
Set second=%time:~6,2%
Set dir=%backup_path%\%year%-%month%-%day%_%hour%%minute%%second%
Set addon=%year%%month%%day%%hour%%minute%%second%
:: Create dir
If not exist%dir% (
mkdir%dir% 2>nul
)
If not exist%dir% (
echo Backup path:%dir% NOT exists, create DIR failed.
Goto exit
)
CD/D%dir%
:: Backup
echo Start Dump databases ...
For%%D in (%databases%) do (
echo Dumping Database%%D ...
%mysql%mysqldump-u%username%-p%password%%%D >%%d.%addon%.sql
:: WinRAR
If exist%winrar% (
%winrar% a-k-r-s-m1-ep1%%d.%addon%.rar%%d.%addon%.sql
del/f/s/q%%d.%addon%.sql 2>null
)
)
Echo Done
: Exit