Azure DevOps 存储库备份副本 [英] Azure DevOps repo Backup Copy
问题描述
我们在
3.逻辑是:如果您的源代码库有任何更改=>将触发管道=>它在 DefaultWorkingDirectory(CMD 任务)中制作最新副本=>将此副本存档到 Backup.zip
文件(存档文件任务=>Azure 文件复制任务会将此 Backup.zip
复制到 Azure 存储 blob)
We have created repository on https://dev.azure.com/ It's working fine. Now my manager wants a backup copy of this repository on a regular basis. I explained to manager that https://dev.azure.com/ is managed as SAAS by MS so repo is safe always. But he wants a copy of own. It is what is it!!
I thought of few options:
a) Get latest on any developer machine and take backup into tape device
b) Use some infra of Azure DevOps to keep backup on Azure Storage
How feasible is option b?
Is backup of Azure DevOps possible with all past check-in history?
Any backup service on Azure DevOps that I can link with Azure Storage?
Is incremental backup possible using some xyz service on Azure DevOps?
How feasible is option b?
It's possible in Azure Devops Service. What you need is a Yaml pipeline which triggers all branches.
You can use command line task to backup the repo into {RepoName}.git
folder, and then copy this folder into Azure Storage using Azure File Copy task. Similar to this:
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
Details:
1.CI Trigger with wildcard(*) can monitor all your branches. So if there's any update with your repo, the pipeline will be triggered to run.
2.The cmd task calls 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
This command will create a RepoName.git
folder which contains the copy of your repo in this path: $(System.DefaultWorkingDirectory)
. To create PAT, you only need to create one with Code-read access scope:
3.The logic is: If there's any change to your source repo=>The pipeline will be triggered=>It make a latest copy in DefaultWorkingDirectory(CMD task)=>Archive this copy into a Backup.zip
file(Archive file task=>Azure File copy task will copy this Backup.zip
to Azure storage blobs)
这篇关于Azure DevOps 存储库备份副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!