windows下备份mysql和网站

最近使用的一个windows2003下的数据库和网站备份脚本,每天晚上备份网站文件和数据库文件,并只保留最近7天的备份。

 

set today=%date:~0,4%-%date:~5,2%-%date:~8,2%
for /f  %%i in ('dir d:\wamp\bin\mysql\mysql5.5.20\data /ad /b ') do d:\wamp\bin\mysql\mysql5.5.20\bin\mysqldump.exe -u root -proot %%i >d:\wamp\sql\%%i.sql
net stop wampapache
net stop wampmysqld
net stop "Apache Tomcat 6.0 Tomcat6"
7z.exe a -tzip ..\files\%today%-wamp.zip d:\wamp\ -mx0 -xr!u_mtc -xr!6027 >..\files\%today%-wamp.log
net start wampmysqld
net start wampapache
net start "Apache Tomcat 6.0 Tomcat6"
del /q d:\wamp\sql\*
dir ..\files\*.zip /a /b >..\files\%today%-deleting.log
forfiles /p ..\files /d -7 /c "cmd /c del /f @path"
dir ..\files\*.zip /a /b >..\files\%today%-deleted.log

 附,备份sql数据库,只保留最近30天的备份

set BPM=D:\BPMDailyBackup
for /f  %%i in ('dir ..\files\*.bak /a /b ') do 7z.exe a -tzip ..\files\%%i.zip ..\files\%%i -mx0 >..\files\%%i.txt
del ..\files\*.bak
forfiles /p ..\files\ /d -30 /c "cmd /c del /f @path"
for /f  %%j in ('dir %BPM%\*.bak /a /b ') do 7z.exe a -tzip %BPM%\%%j.zip %BPM%\%%j -mx0 >%BPM%\%%j.txt
del %BPM%\*.bak
forfiles /p %BPM%\ /d -30 /c "cmd /c del /f @path"

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值