
建站通服务器遭受一次补批量挂码,分析发现特征码一致,因此有规则可寻(最后得出结论是:清理数据库后台挂码记录,清理缓存文件即可,虽然后来发现清理数据库后,后台更新即可,其它都是多余,貌似有点愚蠢,清理缓存文件而不更新后台,会出现打不开或报错的情况,因此不得不恢复原有缓存文件,但这里只讨论为此写下的BAT脚本,以备后用,脚本的通用性很高,思路上很多点值得记录下)。
说干就干开始开启BAT编写之路:
挂码文件及缓存文件清理
讲下1.txt为站点清单,这个文件生成可以参照以前介绍过的脚本获取:
@echo off
::author: by jerry
:: date: 2018-8-30
set webroot=E:\wwwroot
for /f %%a in (1.txt) do call :err_del %%a
:err_del
set DirName=%1%
if exist %webroot%\%DirName%\web (call :screen)
goto :eof
:screen
del %webroot%\%DirName%\web\index.html
echo %webroot%\%DirName%\web\index.html>>muma.log
del %webroot%\%DirName%\web\caches\caches_commons\caches_data\sitelist.cache.php
echo %webroot%\%DirName%\web\caches\caches_commons\caches_data\sitelist.cache.php>>muma.log
goto :eof

恢复指定文件脚本:
@echo off
::author jerry
::date 2019-7
set /p bakdir=指定恢复数据路径(eg:F:\backup\20190722\):
For /f "tokens=2 delims==" %%a IN ('ftype ^|find /i "WinRAR=" ') DO (
For /f "tokens=1-3 delims=\" %%b IN ("%%a") DO (
Set "rar=%%b\%%c\%%d\WinRAR.exe""
Goto:next )
)
:next
echo 程序正在处理中,请稍后……
echo %rar%
for /f %%i in (C:\1.txt) do (
%rar% e -o+ %bakdir%\%%i.rar web\caches\caches_commons\caches_data\sitelist.cache.php E:\wwwroot\%%i\web\caches\caches_commons\caches_data\
)
echo 指定数据恢复成功……
pause

客官点个赞呗! (0)