找回密码
 立即注册
@echo off
::Author: jerry
::Date:2018-11-20
echo.
echo MySQL数据库及网站程序备份脚本
echo
echo Author: jerry
echo Date:2018-11-20
echo 备份日期:%date%
echo 备份时间:%time%
echo.
echo
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set bakdir="D:\Program Files\MySQL51\data"
set sqlcache="C:\mysqlcache"
set webdir="E:\wwwroot"
echo 正在进入MySQL目录。注意:对于有空格的目录,命令行要加引号。"C:\Program Files"
echo 正在备份Mysql数据,请稍等......
if not exist "%sqlcache%" mkdir "%sqlcache%"
for /F %%a in ('dir /ad /b %bakdir%') do (
::echo "%bakdir%\%%a %sqlcache%\%%a" >>a.log
if not exist "%sqlcache%\%%a" mkdir "%sqlcache%\%%a"
xcopy "D:\Program Files\MySQL51\data"\%%a "C:\mysqlcache"\%%a /s /E /y >nul
)
if not exist "F:\mysqlbak\%Ymd%" mkdir "F:\mysqlbak\%Ymd%"
for /f "usebackq tokens=1 delims=/" %%a in (dir /b %sqlcache%) do "C:\Program Files (x86)\WinRAR\WinRAR.exe" a -ep1 -r0 -df -exit -- "F:\mysqlbak\%Ymd%\%%a.rar" %sqlcache%\%%a
echo 数据库备份完成......
echo.
echo 网站数据备份中,请稍后......
if not exist "F:\freehostbackup\%Ymd%" mkdir "F:\freehostbackup\%Ymd%"
for /f "usebackq tokens=1 delims=/" %%i in (dir /b %webdir%) do "C:\Program Files (x86)\WinRAR\WinRAR.exe" a -ep1 -r0 -exit -- "F:\freehostbackup\%Ymd%\%%i.rar" %webdir%\%%i
echo.


上一篇:最新版Discuz! X3.4 R20210320 插件无法启动解决方法。
下一篇:使用GuzzleHttp快速入门及携带cookie