1

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?

LoLance
  • 25,666
  • 1
  • 39
  • 73
ABC DEF
  • 189
  • 2
  • 14
  • 1
    Not sure what you're trying to back up. If it's the source code: it uses git, so you can clone the repo anywhere you want. If it's the Work Items (epics/features/stories/tasks), those are all exportable. Aside from that: this is more of a tooling documentation question, and not a specific programming question. – David Makogon May 21 '20 at 18:39

1 Answers1

2

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:

enter image description here

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)

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • I tried using this same approach but it gives error on first step itself. I have a PAT with full access, and used as above, but it gives 400 error : "fatal: unable to access ". I also tried using Powershell after encoding PAT with base64, but still same issue. Any help on this please. – zainul Mar 17 '21 at 06:13