添加后台代理代码
This commit is contained in:
250
codes/agent/tools/bak/autorun.test.cmd
Normal file
250
codes/agent/tools/bak/autorun.test.cmd
Normal file
@@ -0,0 +1,250 @@
|
||||
echo off
|
||||
echo %date% %time%
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::: 同步战绩数据
|
||||
:sync_recorddata
|
||||
|
||||
:init
|
||||
::: mysql导出工具文件全名
|
||||
set ExportBinary="C:\webroot\dbbackup\mysql\mysqldump.exe"
|
||||
::: mysql导入工具文件全名
|
||||
set ImportBinary="C:\webroot\dbbackup\mysql\mysql.exe"
|
||||
|
||||
|
||||
::: 游戏基础信息服务器配置
|
||||
set Hostname_base="rm-bp16sbf0l9cavp7h9o.mysql.rds.aliyuncs.com"
|
||||
set Hostport_base="3306"
|
||||
set Username_base="develop"
|
||||
set Password_base="develop123!@#"
|
||||
set Database_base="youle_games"
|
||||
set ExportTable_base=player
|
||||
|
||||
::: 游戏战绩服务器配置
|
||||
set Hostname_record="rm-bp16sbf0l9cavp7h9o.mysql.rds.aliyuncs.com"
|
||||
set Hostport_record="3306"
|
||||
set Username_record="develop"
|
||||
set Password_record="develop123!@#"
|
||||
set Database_record="youle_games"
|
||||
set ExportTable_record=player_grade,gold_account
|
||||
|
||||
::: 后台服务器配置
|
||||
set Hostname_owner="localhost"
|
||||
set Hostport_owner="3309"
|
||||
set Username_owner="root"
|
||||
set Password_owner="root_root"
|
||||
set Database_owner="game_db"
|
||||
set Database_owner_temp="game_db_temp"
|
||||
|
||||
::: 临时服务器配置
|
||||
set Hostname_temp="localhost"
|
||||
set Hostport_temp="3309"
|
||||
set Username_temp="root"
|
||||
set Password_temp="root_root"
|
||||
set Database_temp="game_db"
|
||||
set Database_temp_temp="game_db_temp"
|
||||
|
||||
::: 是否需要保存到临时库
|
||||
set NeedSaveToTemp=0
|
||||
|
||||
::: 要执行的脚本
|
||||
set ExecuteCommand_1="call cp_SynchronizeSettle();"
|
||||
|
||||
::: 保证脚本输出目录一定存在
|
||||
if not exist "%~dp0script" md "%~dp0script"
|
||||
|
||||
::: 要导出的脚本文件名的前缀(后面还会加上表名)
|
||||
set ScriptnamePrefix=%~dp0script\%date:~0,4%%date:~5,2%%date:~8,2%
|
||||
|
||||
::: 判断脚本是否存在, 存在则删除
|
||||
::if exist %Scriptname% del %Scriptname%
|
||||
|
||||
:export
|
||||
echo 开始导出游戏基础信息脚本
|
||||
for %%t in (%ExportTable_base%) do (
|
||||
::: 判断脚本是否存在, 存在则删除
|
||||
if exist "%ScriptnamePrefix%_base_%%t.sql" del "%ScriptnamePrefix%_base_%%t.sql"
|
||||
|
||||
::: 循环导出脚本
|
||||
echo 导出表%%t到%ScriptnamePrefix%_base_%%t.sql
|
||||
%ExportBinary% --default-character-set=utf8 --opt -h%Hostname_base% -P%Hostport_base% -u%Username_base% -p%Password_base% %Database_base% %%t > "%ScriptnamePrefix%_base_%%t.sql"
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
)
|
||||
echo 游戏基础信息脚本导出完成
|
||||
|
||||
echo 开始导出游戏战绩脚本
|
||||
for %%t in (%ExportTable_record%) do (
|
||||
::: 判断脚本是否存在, 存在则删除
|
||||
if exist "%ScriptnamePrefix%_record_%%t.sql" del "%ScriptnamePrefix%_record_%%t.sql"
|
||||
|
||||
::: 循环导出脚本
|
||||
echo 导出表%%t到%ScriptnamePrefix%_record_%%t.sql
|
||||
%ExportBinary% --default-character-set=utf8 --opt -h%Hostname_record% -P%Hostport_record% -u%Username_record% -p%Password_record% %Database_record% %%t > "%ScriptnamePrefix%_record_%%t.sql"
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
)
|
||||
echo 游戏战绩脚本导出完成
|
||||
|
||||
:import
|
||||
echo 开始导入游戏基础信息脚本
|
||||
for %%t in (%ExportTable_base%) do (
|
||||
echo 从%ScriptnamePrefix%_base_%%t.sql导入表%%t
|
||||
%ImportBinary% --default-character-set=utf8 -h%Hostname_owner% -P%Hostport_owner% -u%Username_owner% -p%Password_owner% %Database_owner_temp% < "%ScriptnamePrefix%_base_%%t.sql"
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
)
|
||||
echo 游戏基础信息脚本导入完成
|
||||
|
||||
echo 开始导入游戏战绩脚本
|
||||
for %%t in (%ExportTable_record%) do (
|
||||
echo 从%ScriptnamePrefix%_record_%%t.sql导入表%%t
|
||||
%ImportBinary% --default-character-set=utf8 -h%Hostname_owner% -P%Hostport_owner% -u%Username_owner% -p%Password_owner% %Database_owner_temp% < "%ScriptnamePrefix%_record_%%t.sql"
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
)
|
||||
echo 游戏战绩脚本导入完成
|
||||
|
||||
:synchronize
|
||||
echo 执行脚本%ExecuteCommand_1%
|
||||
%ImportBinary% -h%Hostname_owner% -P%Hostport_owner% -u%Username_owner% -p%Password_owner% -e%ExecuteCommand_1% %Database_owner%
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
echo 脚本执行完成
|
||||
|
||||
if %NeedSaveToTemp% equ 0 goto convertdata
|
||||
|
||||
:savetotemp
|
||||
echo 开始导入游戏基础信息脚本到临时库
|
||||
for %%t in (%ExportTable_base%) do (
|
||||
echo 从%ScriptnamePrefix%_base_%%t.sql导入表%%t
|
||||
%ImportBinary% --default-character-set=utf8 -h%Hostname_temp% -P%Hostport_temp% -u%Username_temp% -p%Password_temp% %Database_temp_temp% < "%ScriptnamePrefix%_base_%%t.sql"
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
)
|
||||
echo 游戏基础信息脚本导入完成
|
||||
|
||||
echo 开始导入游戏战绩脚本到临时库
|
||||
for %%t in (%ExportTable_record%) do (
|
||||
echo 从%ScriptnamePrefix%_record_%%t.sql导入表%%t
|
||||
%ImportBinary% --default-character-set=utf8 -h%Hostname_temp% -P%Hostport_temp% -u%Username_temp% -p%Password_temp% %Database_temp_temp% < "%ScriptnamePrefix%_record_%%t.sql"
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
)
|
||||
echo 游戏战绩脚本导入完成
|
||||
|
||||
|
||||
echo 执行同步脚本
|
||||
echo 执行脚本%ExecuteCommand_1%
|
||||
%ImportBinary% -h%Hostname_temp% -P%Hostport_temp% -u%Username_temp% -p%Password_temp% -e%ExecuteCommand_1% %Database_temp%
|
||||
if %errorlevel% neq 0 goto exit_recorddata
|
||||
echo 脚本执行完成
|
||||
|
||||
:convertdata
|
||||
::"%~dp0MySqlSynchronize.exe"
|
||||
|
||||
:clean
|
||||
echo 删除脚本文件
|
||||
for %%t in (%ExportTable_base%) do del "%ScriptnamePrefix%_base_%%t.sql"
|
||||
for %%t in (%ExportTable_record%) do del "%ScriptnamePrefix%_record_%%t.sql"
|
||||
echo 脚本删除完成
|
||||
|
||||
:sync_recorddata
|
||||
echo %date% %time%
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::: 同步报表
|
||||
:sync_reportdata
|
||||
echo 开始同步报表数据(https://proxytest.tscce.cn/api/ext/SynchronizeReportData.php)
|
||||
"%~dp0HttpRequest.x64.exe" -type post -address "https://proxytest.tscce.cn/api/ext/SynchronizeReportData.php" -parameter "" -interval 1000 -thread 1 -loop 0
|
||||
echo 开始生成报表数据(https://proxytest.tscce.cn/api/ext/autotask.php)
|
||||
"%~dp0HttpRequest.x64.exe" -type post -address "https://proxytest.tscce.cn/api/ext/autotask.php" -parameter "" -interval 1000 -thread 1 -loop 0
|
||||
goto exit
|
||||
|
||||
:exit_reportdata
|
||||
echo %date% %time%
|
||||
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::: 备份数据库
|
||||
:backup_database
|
||||
for /f "tokens=1-3 delims=/-, " %%a in ('echo/%date%') do (
|
||||
set yy=%%a & set mm=%%b & set dd=%%c
|
||||
)
|
||||
set /a dd=100%dd%%%100,mm=100%mm%%%100
|
||||
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
|
||||
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
|
||||
|
||||
set /a j=j-7
|
||||
|
||||
set /a i=j,a=i+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
|
||||
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5
|
||||
set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
|
||||
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
|
||||
|
||||
set fdate=%yy%-%mm%-%dd%
|
||||
echo %fdate%
|
||||
|
||||
set mysqldump=C:\xampp\mysql\bin\mysqldump.exe
|
||||
set mysql=C:\xampp\mysql\bin\mysql.exe
|
||||
set winrar=C:\Program Files\WinRAR\rar.exe
|
||||
set needupload=0
|
||||
|
||||
::: 开始备份oracle(dbcenter)
|
||||
if exist "%~dp0dbcenter_%yy%%mm%%dd%.dmp" del "%~dp0dbcenter_%yy%%mm%%dd%.dmp"
|
||||
if exist "%~dp0dbcenter_%yy%%mm%%dd%.log" del "%~dp0dbcenter_%yy%%mm%%dd%.log"
|
||||
|
||||
set NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
||||
set ORACLE_HOME=D:\app\kingsoft\virtual\product\12.2.0\dbhome_1
|
||||
exp '"/ as sysdba"' file="%~dp0dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.dmp" log="%~dp0dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.log" grants=y full=y statistics=none
|
||||
::: 备份oracle(dbcenter)结束
|
||||
|
||||
::: 开始备份mysql(tswldb)
|
||||
if exist "%~dp0tswldb_%yy%%mm%%dd%.sql" del "%~dp0tswldb_%yy%%mm%%dd%.sql"
|
||||
"%mysqldump%" --opt -hlocalhost -P3309 -uroot -proot_root -R tswldb > "%~dp0tswldb_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
::: 备份mysql(tswldb)结束
|
||||
|
||||
::: 开始备份mysql(syhd)
|
||||
if exist "%~dp0syhd_%yy%%mm%%dd%.sql" del "%~dp0syhd_%yy%%mm%%dd%.sql"
|
||||
"%mysqldump%" --opt -hlocalhost -P3309 -uroot -proot@admin -R syhd > "%~dp0syhd_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
::: 备份mysql(syhd)结束
|
||||
|
||||
::: 开始备份mysql(game_db)
|
||||
if exist "%~dp0game_db_localhost_%yy%%mm%%dd%.sql" del "%~dp0game_db_localhost_%yy%%mm%%dd%.sql"
|
||||
"%mysql%" -h"localhost" -P"3309" -uroot -proot_root -e"truncate table player_grade" game_db
|
||||
"%mysqldump%" --opt -h"localhost" -P"3309" -uroot -proot_root -R game_db > "%~dp0game_db_localhost_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
::: 备份mysql(game_db)结束
|
||||
|
||||
|
||||
::: 开始备份mysql(youlehudong)
|
||||
if exist "%~dp0youlehudong_%yy%%mm%%dd%.sql" del "%~dp0youlehudong_%yy%%mm%%dd%.sql"
|
||||
"%mysqldump%" --opt -h"rm-wz978o3vha6z26m5no.mysql.rds.aliyuncs.com" -P"3306" -u"yunuser" -p"Yun_User" -R youlehudong > "%~dp0youlehudong_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
::: 备份mysql(youlehudong)结束
|
||||
|
||||
::: 开始备份mysql(game_db)
|
||||
"%mysql%" -h"rm-wz978o3vha6z26m5no.mysql.rds.aliyuncs.com" -P"3306" -u"yunuser" -p"Yun_User" -e"truncate table player_grade" game_db
|
||||
"%mysql%" -h"rm-wz978o3vha6z26m5no.mysql.rds.aliyuncs.com" -P"3306" -u"yunuser" -p"Yun_User" -e"truncate table coin_rebate" game_db
|
||||
if exist "%~dp0game_db_%yy%%mm%%dd%.sql" del "%~dp0game_db_%yy%%mm%%dd%.sql"
|
||||
"%mysqldump%" --opt -h"rm-wz978o3vha6z26m5no.mysql.rds.aliyuncs.com" -P"3306" -u"yunuser" -p"Yun_User" -R game_db > "%~dp0game_db_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
::: 备份mysql(game_db)结束
|
||||
|
||||
|
||||
::: 压缩备份文件
|
||||
%~d0
|
||||
cd "%~dp0"
|
||||
if exist "%~dp0database_%yy%%mm%%dd%.rar" del "%~dp0database_%yy%%mm%%dd%.rar"
|
||||
"%winrar%" a "database_%date:~0,4%%date:~5,2%%date:~8,2%.rar" "dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.dmp" "dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.log" "tswldb_%date:~0,4%%date:~5,2%%date:~8,2%.sql" "syhd_%date:~0,4%%date:~5,2%%date:~8,2%.sql" "game_db_localhost_%date:~0,4%%date:~5,2%%date:~8,2%.sql" "youlehudong_%date:~0,4%%date:~5,2%%date:~8,2%.sql" "game_db_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
if %needupload% NEQ 0 (
|
||||
::: 上传压缩文件
|
||||
"%~dp0NetworkTool.x64.exe" -st "2" -rt "2" -hn "120.76.157.63" -hp "80" -on "/dbbackup/upload.php" -rd "/" -rf "database_%date:~0,4%%date:~5,2%%date:~8,2%.rar" -lf "%~dp0database_%date:~0,4%%date:~5,2%%date:~8,2%.rar"
|
||||
::: 删除压缩文件
|
||||
:::del "database_%date:~0,4%%date:~5,2%%date:~8,2%.rar"
|
||||
)
|
||||
|
||||
::: 删除备份的文件
|
||||
if exist "%~dp0dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.dmp" del "%~dp0dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.dmp"
|
||||
if exist "%~dp0dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.log" del "%~dp0dbcenter_%date:~0,4%%date:~5,2%%date:~8,2%.log"
|
||||
if exist "%~dp0tswldb_%date:~0,4%%date:~5,2%%date:~8,2%.sql" del "%~dp0tswldb_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
if exist "%~dp0syhd_%date:~0,4%%date:~5,2%%date:~8,2%.sql" del "%~dp0syhd_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
if exist "%~dp0game_db_localhost_%date:~0,4%%date:~5,2%%date:~8,2%.sql" del "%~dp0game_db_localhost_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
if exist "%~dp0youlehudong_%date:~0,4%%date:~5,2%%date:~8,2%.sql" del "%~dp0youlehudong_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
if exist "%~dp0game_db_%date:~0,4%%date:~5,2%%date:~8,2%.sql" del "%~dp0game_db_%date:~0,4%%date:~5,2%%date:~8,2%.sql"
|
||||
|
||||
::: 备份完毕
|
||||
:exit
|
||||
|
||||
echo on
|
||||
pause
|
||||
Reference in New Issue
Block a user