今天迁移服务器,Windows2008(阿里云),突然找到一个批处理文件,原来一两年前,我还写过批处理来备份数据库,现在看起来很诡异的样子,当年到底怎么写出来的。。。。。

@echo off
set "ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set storeDir="F:\databases\%ymd%"
set /A keepFromDay=%ymd%-7

md %storeDir% 2>nul
"E:\xampp\mysql\bin\mysqldump.exe"  -u*** -p*** --lock-tables   --all-databases > %storeDir%\db.sql 2>nul
echo Haozip loading...
cd /d %storeDir%

"C:\Program Files\HaoZip\HaoZipC.exe" a -tzip db.sql.zip db.sql
del /q db.sql

rem del 7 days backup files
@echo off

for /f %%i in ('dir /b ..\') do (
   if %%i LSS %keepFromDay%   (
	echo deleting %%i 
	rd /s /q "F:\databases\%%i" 
   )	
)

echo Finish at  %date% %time%  >> ../backup.log

- EOF -