Azure DevOps 存储库备份副本
Azure DevOps repo Backup Copy
我们已经在 https://dev.azure.com/ 上创建了存储库
它工作正常。
现在,我的经理想要定期备份此存储库。
我向经理解释说 https://dev.azure.com/ 由 MS 作为 SAAS 进行管理,因此回购始终是安全的。
但他想要一份属于自己的副本。它就是它!!
我想到了几个选项:
a) 在任何开发机器上获取最新版本并备份到磁带设备
b) 使用 Azure DevOps 的一些基础设施在 Azure 存储上保持备份
选项b的可行性如何?
Azure DevOps 的备份是否可以包含所有过去的签入历史记录?
我可以 link 使用 Azure 存储的任何 Azure DevOps 备份服务?
是否可以在 Azure DevOps 上使用某些 xyz 服务进行增量备份?
How feasible is option b?
在 Azure Devops 服务中是可能的。你需要的是 Yaml pipeline which triggers all branches.
您可以使用 command line task to backup the repo into {RepoName}.git
folder, and then copy this folder into Azure Storage using Azure File Copy task。类似这样:
trigger:
branches:
include:
- '*'
pool:
vmImage: 'windows-latest'
steps:
- task: CmdLine@2
inputs:
script: 'git clone --mirror https://{Your PAT}@dev.azure.com/{OrgName}/{ProjectName}/_git/{RepoName}'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/{RepoName}.git'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/Backup.zip'
replaceExistingArchive: true
- task: AzureFileCopy@4
displayName: 'AzureBlob File Copy'
inputs:
SourcePath: '$(Build.ArtifactStagingDirectory)/Backup.zip'
azureSubscription: xxxx
Destination: AzureBlob
storage: xxxxxxxx
ContainerName: arm
BlobPrefix: test
详情:
1.CI 带通配符(*)的触发器可以监控你所有的分支。因此,如果您的存储库有任何更新,管道将被触发到 运行.
2.The cmd 任务调用 git clone --mirror to make the copy of your git repo. To copy Azure Git repo in cmd task with PAT, you can follow the format here:
git clone https://{yourPAT}@dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
此命令将创建一个 RepoName.git
文件夹,其中包含此路径中的存储库副本:$(System.DefaultWorkingDirectory)
。到create PAT,你只需要创建一个代码读取访问范围:
3.The 逻辑是:如果您的源代码库有任何更改=>管道将被触发=>它在 DefaultWorkingDirectory(CMD 任务)中制作最新副本=>将此副本存档到 Backup.zip
文件(Archive file task=>Azure 文件复制任务会将此 Backup.zip
复制到 Azure 存储 blob)
我们已经在 https://dev.azure.com/ 上创建了存储库 它工作正常。 现在,我的经理想要定期备份此存储库。 我向经理解释说 https://dev.azure.com/ 由 MS 作为 SAAS 进行管理,因此回购始终是安全的。 但他想要一份属于自己的副本。它就是它!!
我想到了几个选项:
a) 在任何开发机器上获取最新版本并备份到磁带设备
b) 使用 Azure DevOps 的一些基础设施在 Azure 存储上保持备份
选项b的可行性如何?
Azure DevOps 的备份是否可以包含所有过去的签入历史记录?
我可以 link 使用 Azure 存储的任何 Azure DevOps 备份服务?
是否可以在 Azure DevOps 上使用某些 xyz 服务进行增量备份?
How feasible is option b?
在 Azure Devops 服务中是可能的。你需要的是 Yaml pipeline which triggers all branches.
您可以使用 command line task to backup the repo into {RepoName}.git
folder, and then copy this folder into Azure Storage using Azure File Copy task。类似这样:
trigger:
branches:
include:
- '*'
pool:
vmImage: 'windows-latest'
steps:
- task: CmdLine@2
inputs:
script: 'git clone --mirror https://{Your PAT}@dev.azure.com/{OrgName}/{ProjectName}/_git/{RepoName}'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/{RepoName}.git'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/Backup.zip'
replaceExistingArchive: true
- task: AzureFileCopy@4
displayName: 'AzureBlob File Copy'
inputs:
SourcePath: '$(Build.ArtifactStagingDirectory)/Backup.zip'
azureSubscription: xxxx
Destination: AzureBlob
storage: xxxxxxxx
ContainerName: arm
BlobPrefix: test
详情:
1.CI 带通配符(*)的触发器可以监控你所有的分支。因此,如果您的存储库有任何更新,管道将被触发到 运行.
2.The cmd 任务调用 git clone --mirror to make the copy of your git repo. To copy Azure Git repo in cmd task with PAT, you can follow the format here:
git clone https://{yourPAT}@dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
此命令将创建一个 RepoName.git
文件夹,其中包含此路径中的存储库副本:$(System.DefaultWorkingDirectory)
。到create PAT,你只需要创建一个代码读取访问范围:
3.The 逻辑是:如果您的源代码库有任何更改=>管道将被触发=>它在 DefaultWorkingDirectory(CMD 任务)中制作最新副本=>将此副本存档到 Backup.zip
文件(Archive file task=>Azure 文件复制任务会将此 Backup.zip
复制到 Azure 存储 blob)