把下面代码复制粘贴到记事本上,保存为后缀为bat文件。
备份网站程序、MYSQL、MSSQL
@echo off REM - File: bkup.bat REM - Description: Restart's IIS (Web, FTP,MYSQL,MSSQL) REM - Author: databases back REM - ADD REM comments if you don't want to restart any REM - of Services echo ====================================================== echo 正在停止IIS、FTP、MYSQL、MSSQL等服务…… echo ====================================================== net stop "World Wide Web Publishing Service" net stop "IIS Admin Service" net stop "W3SVC" net stop "serv-u" net stop "MySQLa" net stop "SQLSERVERAGENT" net stop "MSSQLSERVER" echo ====================================================== echo 运行备份,需要去掉echo保存即可! echo 正在备份MYSQL文件夹,请不要关闭窗口! ... echo ====================================================== Xcopy "d:\MySQL\data" "d:\bkup\mysql\" /e/I/d/h/r/y/q echo Xcopy "d:\MySQL\data" "d:\bkup\mysql\%date:~0,10%\data\" /e/I/d/h/r/y/q echo ====================================================== echo 正在备份MSSQL文件夹,请不要关闭窗口! ... Xcopy "d:\mssql" "d:\bkup\mssql\" /e/I/d/h/r/y/q echo Xcopy "d:\mssql" "d:\bkup\mssql\%date:~0,10%\data\" /e/I/d/h/r/y/q echo ====================================================== echo 正在备份网站程序,请不要关闭窗口! echo Xcopy "d:\wwwroot" "d:\bkup\web\" /e/I/d/h/r/y/q echo ====================================================== echo 正在启动IIS、FTP、MYSQL、MSSQL等服务…… echo ====================================================== net start "World Wide Web Publishing Service" net start "IIS Admin Service" net start "W3SVC" net start "serv-u" net start "MySQLa" net start "MSSQLSERVER" net start "SQLSERVERAGENT"
备份Access数据库,并打包压缩文件,删除N天前的文件。
@echo off echo ====================================================== echo 正在备份Access数据库文件... 请不要关闭窗口! echo ====================================================== setlocal enabledelayedexpansion for /f "delims=" %%i in ('dir/a-d/s/b/l/on "d:\wwwroot\*.mdb"') do ( if /i "%%~nxi"=="shujukumingcheng.mdb" ( set "name_dp=%%~dpi" set "name_dp=!name_dp:d:\wwwroot\=e:\bkup\databases\!" xcopy/y "%%i" "!name_dp!" ) ) echo ====================================================== echo 完成数据库备份!正在建立数据库压缩文件... 请不要关闭窗口! echo ====================================================== md "e:\bkup\package" "d:\Green\WinRAR\WinRAR.exe" a -ibck -m3 -agyyyy-mm-dd "e:\bkup\package\" "e:\bkup\databases" echo rd /s /q e:\bkup\databases echo ====================================================== echo 完成数据库压缩文件!正在删除前七天的备份! echo ====================================================== forfiles /p e:\bkup\package /m *.rar -d -7 /c "cmd /c del /f @path"
备份数据到内网主机
@echo off echo ====================================================== echo 备份数据到内网主机,连接登录共享主机!******(修改为自己的密码) echo ====================================================== net use \\192.168.1.2\ipc$ *******/user:administrator echo ====================================================== echo 正在备份网站程序! echo 请不要关闭窗口! echo ====================================================== xcopy "d:\Backup" "\\192.168.1.2\Backup" /e/I/d/h/r/y/q
自动重启服务器
@echo off echo ====================================================== echo 自动重新启动(-r表示重启,-f表示关闭未响应程序,-t表示时间后面跟随等待秒数,0为马上重启) echo ====================================================== shutdown -r -f -t 0
提取当前文件夹里面的文件名
@echo off dir *.*? /a-d /o:d /b >提取文件名.txt
建站咨询热线
029-33273980