forfiles /p "D:DBBackup" /m "*.sql" /d -08 /c "cmd /c del @path"
forfiles /p "D:DBBackupackuplog" /m "*.rar" /d -03 /c "cmd /c del @path"
@echo off
set errorlevel=0
set DBUser=backup
set DBPassword=passwd
set IP=192.168.1.1
set port=3306
mysql -u%DBUser% -p%DBPassword% -h%IP% -P%port% < D:DBBackupscriptsdbname.sql > D:/DBBackup/logdbname.txt
D:
cd D:/DBBackup
more +1 logdbname.txt > logdbname.tmp
del logdbname.txt
ren logdbname.tmp logdbname.txt
for /f "tokens=1 delims= " %%i in (D:/DBBackup/logdbname.txt) do mysqldump -u%DBUser% -p%DBPassword% -h%IP% -P%port% %%i > D:/DBBackup/%%i_%date:~0,4%%date:~5,2%%date:~8,2%.sql
for /f "tokens=1 delims= " %%i in (D:/DBBackup/logdbname.txt) do start /wait C:"Program Files"WinRARWinRAR.exe -Y U -agYYYYMMDD -ep1 D:DBBackupackuplog\%%i_.rar D:DBBackup\%%i_%date:~0,4%%date:~5,2%%date:~8,2%*.sql