azure - TeamCity 按计划备份并复制到 Azure,REST 脚本改进
问题描述
我正在编写一个脚本来按计划运行 TeamCity 备份,因为默认情况下它没有这样的选项,然后将其复制到 Azure 存储帐户。
该脚本正在运行,但我想做一些改进。
- 我希望 Powershell 检查备份文件的可用性以供下载(Test-Path 等)。现在,它只需要休眠 360 秒。
- 我想在 Azure 存储帐户上配置保留策略。
#API key for TeamCity as TC parameter $key = "%key%" $date = Get-Date -Format "yyyy-MM-dd" $file = "TeamCity-Backup-$date.zip" #URI for initialize backup $uri = "https://teamcity.test.com/app/rest/server/backup?addTimestamp=false&includeConfigs=true&includeDatabase=true&includeBuildLogs=false&fileName=$file" #URI for downloading backup $uri1 = "https://teamcity.test.com/get/file/backup/$file" $header = @{ "Authorization"="Bearer $key" } #Initialize Invoke-RestMethod -Method Post -Uri $uri -Header $header #Wait for backup sleep -Seconds 360 # #Need function or method for checking file availibility # #Download Invoke-RestMethod -Method Get -Uri $uri1 -Header $header -OutFile "$file" #Key to BLOB $key_storage = "%key_storage%" #Copy to Azure azcopy.exe copy $file "https://myblob.blob.core.windows.net/teamcity-backups$key_storage" # #Funtion for retention Azure Blob #
解决方案
推荐阅读
- javascript - Xamarin Forms WebView 不会打开指向新选项卡的链接
- cluster-computing - slurm 请求整个节点
- python - tkinter 中的问答游戏 - 类问题
- r - 在分类轴上的绘图中添加垂直参考线
- google-sheets - 如何引用特定单元格中的查询数据
- python - 如何使用检查递归获取源代码?
- azure - 如何将文件从 Azure 文件共享复制到 Azure Blob?
- javascript - 如何在数据库中的单个表单中显示数据
- python - 大麻页面刮,尴尬的布局
- powerbi - 使用“List.Zip”替换 Power Query / Power BI / M 代码中的多个列值