Skip to content

leffen/backup_azure_devops_repos

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Backup Azure Devops Repos

Introduction

Azure devops formerly known as visual studio team service is a SAAS for devops. It is a good practice to back up the source code regularly or even, it may be required by the company. However, there is no out of box solution according to microsoft.

Although Microsoft does commit to keep data safe:

But we have no control over the backup mentioned above. Here I recommend several ways to do the backup:

  1. use Backrightup and integrate using its plugin into azure devops. Very easy and it can backup not only source code but also pipelines. Good service good price. The cost is per repo, therefore if you have many repositories, the price might be high.
  2. use cron job on vm use git clone to copy the repo. The drawback is that every time when there is a new repo, you have to change the cron job.
  3. use azure devops rest api to programmably backup the source code.

Option 1 and 2 are pretty obvious. Let us check how we could backup the repo based on the third option.

Backup Azure Devops Repos

This solution is based on python, so that it could be used in either windows or linux environment.

1. Get an Azure DevOps API personal access token(PAT)

  • go to right upper corner click personal access tokens.

  • specify required fields in following picture to create a pat and copy it. (make sure the pat has code reading right)

2. Clone the backup code based on python

The source code could be found at here at github. Clone it and replace the organization and PAT with your own data.

The code uses azure devops rest api to get project list and then all repos url based on project list. At last, the code calls git cmd to clone the repo.

3. Run Backup Code as Cron or Scheduler Jobs

Depending on ur environment, you could run the backup code in windows as a scheduler job or in linux as cron job. Or you could even run it as function app in azure.

About

backup azure devops repos using python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%