bat脚本,备份数据库并压缩

forfiles /p "D:\DBBackup" /m "*.sql" /d -08 /c "cmd /c del @path"
forfiles /p "D:\DBBackup\backuplog" /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:\DBBackup\scripts\dbname.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"\WinRAR\WinRAR.exe -Y U -agYYYYMMDD -ep1  D:\DBBackup\backuplog\%%i_.rar D:\DBBackup\%%i_%date:~0,4%%date:~5,2%%date:~8,2%*.sql

上一篇:java Session统计在线用户,并且显示在线用户


下一篇:Python----爬虫入门系列等