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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。