提交 0e61267c authored 作者: 陈泽健's avatar 陈泽健

feat(deploy): 重构更新脚本,添加完整备份功能

- 重命名脚本文件为 pull_remote_devlop.py
- 完善前端和后端的备份逻辑
- 优化更新流程,增加错误处理和日志记录
- 改进前端更新方式,采用整体备份和逐个更新
- 添加后端JAR文件备份功能
- 修复部分功能模块和参数配置
上级 87b429a0
# 预定系统内部服务打包上传服务器(执行此方法会自动执行upload_saveto_pan.ps1)
# 内部程序,执行编译与更新,调用build_local.sh
$Port = 22
$RemoteUser = "root"
# 变量赋值,切换服务器时需要调整
# 5.186
# $RemoteIP = "139.159.163.86"
# $RemotePath_inner = "/var/www/java/api-java-meeting2.0"
# $RemotePath_external = "/var/www/java/external-meeting-api"
#
# $RunCommand_inner = "docker exec ujava2 /var/www/java/api-java-meeting2.0/run.sh;"
# $RunCommand_external = "docker exec ujava2 /var/www/java/external-meeting-api/run.sh;"
# 5.218
# $RemoteIP = "139.159.163.86"
# $RemotePath_inner = "/var/www/java/api-java-meeting2.0"
# $RemotePath_external = "/var/www/java/external-meeting-api"
#
# $RunCommand_inner = "docker exec ujava2 /var/www/java/api-java-meeting2.0/run.sh;"
# $RunCommand_external = "docker exec ujava2 /var/www/java/external-meeting-api/run.sh;"
# 兰州中石化项目
$RemoteIP = "139.159.163.86"
$RemotePath_inner = "/var/www/java/api-java-meeting2.0"
$RemotePath_external = "/var/www/java/external-meeting-api"
$RunCommand_inner = "docker exec ujava2 /var/www/java/api-java-meeting2.0/run.sh;"
$RunCommand_external = "docker exec ujava2 /var/www/java/external-meeting-api/run.sh;"
# scp 上传本地脚本到远程服务器执行的目录:上传至预定内部服务路径
scp -P $Port "\\192.168.9.9\deploy\01会议预定\标准版本-长期运维\01版本管理\01后端运行服务\内部预定\COM_虹软4.0_V2.1.2526.586_2025_06_25_psl自测\ubains-meeting-inner-api-1.0-SNAPSHOT.jar" "${RemoteUser}@${RemoteIP}:${RemotePath_inner}"
# scp 上传本地脚本到远程服务器执行的目录:上传至预定外部服务路径
scp -P $Port "\\192.168.9.9\deploy\01会议预定\标准版本-长期运维\01版本管理\01后端运行服务\对外预定\COMVhx2.0.2526.234_2025_06_25_dhh自测\ubains-meeting-api-1.0-SNAPSHOT.jar" "${RemoteUser}@${RemoteIP}:${RemotePath_external}"
# ssh 在远程服务器执行脚本
# 更新预定对内服务
ssh -p $Port "${RemoteUser}@${RemoteIP}" "${RunCommand_inner}"
# 更新预定对外服务
ssh -p $Port "${RemoteUser}@${RemoteIP}" "${RunCommand_external}"
# 调用 upload_saveto_pan.ps1 脚本
# Write-Host "调用 upload_saveto_pan.ps1 脚本"
# $uploadScriptPath = ".\upload_saveto_pan.ps1"
# & $uploadScriptPath
\ No newline at end of file
# 预定系统内部服务将包上传到企业网盘
# 忽略 SSL 证书验证(如果仍然需要)
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# 源文件路径
$SourceDirectory = ".\..\ubains-meeting-inner-api\target\ubains-meeting-inner-api-1.0-SNAPSHOT.jar"
$ReadmeSourcePath = ".\..\ubains-meeting-inner-api\README.md"
# 目标文件名
$PackageName = "ubains-meeting-inner-api-1.0-SNAPSHOT.jar"
$PackageNameReadme = "README.md"
# 读取 packageVersion.txt 文件的内容并设置自定义文件夹名称
$testFilePath = ".\..\ubains-meeting-common\src\main\resources\packageVersion.txt"
if (Test-Path -Path $testFilePath) {
$CustomFolder = Get-Content -Path $testFilePath -Raw -Encoding UTF8
Write-Host "自定义文件夹名称: $CustomFolder"
} else {
Write-Host "文件 $testFilePath 未找到"
exit 1
}
# 清理路径中的非法字符,保留字母、数字、中文字符和点号
$CustomFolder = [System.Text.RegularExpressions.Regex]::Replace($CustomFolder, '[^a-zA-Z0-9\u4e00-\u9fa5.]', '_')
# 公司网盘的本地映射路径
# $WebDavBasePath = "\\192.168.9.9\研发管理\01会议预定\标准版本-长期运维\01版本管理\01后端运行服务\内部预定"
# TODO 3.1.1.0版本使用 开始配置
# $WebDavBasePath = "\\192.168.9.9\deploy\01会议预定\标准版本-长期运维\01版本管理\01后端运行服务\内部预定\COM_虹软3.0"
# TODO 3.1.1.0版本使用 结束配置
# TODO 4.1.1.0版本使用 开始配置
$WebDavBasePath = "\\192.168.9.9\deploy\01会议预定\标准版本-长期运维\01版本管理\01后端运行服务\内部预定"
# TODO 4.1.1.0版本使用 结束配置
# 构建完整的上传路径
$WebDavUrl = Join-Path -Path $WebDavBasePath -ChildPath $CustomFolder
$WebDavFilePath = Join-Path -Path $WebDavUrl -ChildPath $PackageName
$WebDavReadmePath = Join-Path -Path $WebDavBasePath -ChildPath "README.md"
# 临时路径(这里不需要临时路径,直接使用源文件路径)
$TempPath = $SourceDirectory
# 确保自定义文件夹存在
if (-Not (Test-Path -Path $WebDavUrl)) {
New-Item -Path $WebDavUrl -ItemType Directory -Force | Out-Null
Write-Host "创建网盘文件夹: $WebDavUrl"
}
# 将文件复制到公司网盘的本地映射路径
Write-Host "开始上传jar包..."
Copy-Item -Path $TempPath -Destination $WebDavFilePath -Force
Write-Host "jar包上传完成"
# 上传README.md文件
Write-Host "开始上传README.md..."
Copy-Item -Path $ReadmeSourcePath -Destination $WebDavReadmePath -Force
Write-Host "README.md上传完成"
# 打印上传路径
Write-Host "jar文件已上传到: $WebDavFilePath"
Write-Host "README.md已上传到: $WebDavReadmePath"
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论