|
WIKI系统没有自带的备份工具,手动备份起来比较麻烦,可以用一个批处理来备份,包括数据库和wiki系统,思路是备份数据库然后将wiki文件夹压缩完全备份。
批处理代码如下:
@echo off
echo 如果当天已有备份,继续操作将删除原有备份!
echo. & pause
del %date:~0,4%-%date:~5,2%-%date:~8,2%\*.* /q
rd %date:~0,4%-%date:~5,2%-%date:~8,2%
echo 成功清除已有备份文件!
echo 删除当天已备份文件夹%date:~0,4%-%date:~5,2%-%date:~8,2%
echo.
del foldlist.txt
dir /a:d /o:-n /b >> foldlist.txt
for /F "skip=5" %%i IN (foldlist.txt) do del %%i /q & rd %%i & echo 删除备份文件夹%%i>>log.txt
echo 成功清除5次之前的备份文件!
echo .
echo 按日期创建备份文件夹:%date:~0,4%-%date:~5,2%-%date:~8,2%成功!
mkdir %date:~0,4%-%date:~5,2%-%date:~8,2%
echo .
echo 开始备份数据库qianzhiwikidb_%date:~0,4%%date:~5,2%%date:~8,2%.sql到%date:~0,4%-%date:~5,2%-%date:~8,2%中,请稍候......
rem 以下内容需要根据实际情况修改:mysqldump文件的实际位置、MySQL的用户名和密码、需要备份的数据库名
C:\wamp\mysql\bin\mysqldump --user=root --password=123 qianzhiwikidb>%date:~0,4%-%date:~5,2%-%date:~8,2%\qianzhiwikidb_%date:~0,4%%date:~5,2%%date:~8,2%.sql
rem 以上内容需要根据实际情况修改:mysqldump文件的实际位置、MySQL的用户名和密码、需要备份的数据库名
echo .
echo 成功备份数据库,备份时间:%date:~0,4%-%date:~5,2%-%date:~8,2% >> log.txt
echo 开始压缩wiki系统并备份qianzhiwiki_%date:~0,4%%date:~5,2%%date:~8,2%.rar到%date:~0,4%-%date:~5,2%-%date:~8,2%中,请稍候......
rem copy "C:\Program Files\WinRAR\WinRAR.exe" WinRAR.exe
rem 将WinRAR.exe拷贝到当前目录,路径中有空格需加双引号
winrar A -o+ -ibck -ep1 %date:~0,4%-%date:~5,2%-%date:~8,2%\qianzhiwikidb_%date:~0,4%%date:~5,2%%date:~8,2%.rar %date:~0,4%-%date:~5,2%-%date:~8,2%\qianzhiwikidb_%date:~0,4%%date:~5,2%%date:~8,2%.sql
del %date:~0,4%-%date:~5,2%-%date:~8,2%\qianzhiwikidb_%date:~0,4%%date:~5,2%%date:~8,2%.sql
rem 压缩并删除源文件
winrar A -o+ -ibck -ep1 %date:~0,4%-%date:~5,2%-%date:~8,2%\qianzhiwiki_%date:~0,4%%date:~5,2%%date:~8,2%.rar C:\wamp\www\QianzhiWiki
rem 参数-ibck是后台运行的意思,-o+覆盖,-ep1不保存文件夹前面路径
echo .
echo 成功备份wiki系统!
echo 成功备份wiki系统,备份时间:%date:~0,4%-%date:~5,2%-%date:~8,2% >> log.txt
|
|