hostease主机优惠

Mediawiki中文技术论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3844|回复: 0

利用批处理备份Mediawiki系统

[复制链接]
发表于 2011-6-25 15:15:47 | 显示全部楼层 |阅读模式
美国主机侦探
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

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

BlueHost美国主机优惠码

Archiver|手机版|小黑屋|Mediawiki中文技术论坛

GMT+8, 2024-11-24 20:41 , Processed in 0.039210 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表