.bat 文件的使用

操作系统的批处理文件,就是可以把DOS命令批量执行的文件。

 

https://jingyan.baidu.com/article/a3a3f811cd5a0b8da2eb8aba.html  (参考地址)

 

例:

1.查看本机ip

hostname
ipconfig/all
ping www.baidu.com
pause

 

2.备份数据库

rem ******MySQL backup start********
@echo off
forfiles /p "D:\备份\数据库备份" /m backup_*.sql -d -30 /c "cmd /c del /f @path"
set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%"
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump" -uroot -pEd987654 "bluetooth" > "D:\备份\数据库备份\backup_%Ymd%.sql"
@echo on
rem ******MySQL backup end********

 

3.压缩备份代码

rem ******MySQL backup start********
@echo off
forfiles /p "D:\备份\发布软件备份" /m website_*.rar -d -30 /c "cmd /c del /f @path"
set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%"

"C:\Program Files (x86)\WinRAR\Rar.exe" a -r -s -m1 "D:\备份\发布软件备份\website_%Ymd%.rar" "D:\website"

@echo on
rem ******MySQL backup end********

 

posted @ 2018-11-09 11:50  炽橙子  阅读(199)  评论(0编辑  收藏  举报