Microsoft doesn't provide any built-in solution to backup the Azure Devops Services.
They ask them to trust the process as described in the Data Protection Overview page.
However most companies want to keep an on-premise backup of their code repositories for their Disaster Recovery Plan (DRP).
This project provides a bash script to backup all azure devops repositories of an Azure Devops Organization.
A PowerShell version of this script has been developped by Pacman1988
- Shell bash (If you're running on windows, use WSL2 to easily run a GNU/Linux environment)
- Azure CLI : Installation guide
- Azure CLI - Devops Extension : Installation guide
- jq, base64 packages (available in most Linux distributions)
Interaction with the Azure DevOps API requires a personal access token.
For this backup script you'll only need to generate a PAT with read access on Code
./backup-devops.sh -o DEVOPS_ORG_URL -p DEVOPS_PAT -d BACKUP_DIRECTORY --dryrun true --verbose true
Parameters:
-o | --organization:
The azure devops organisation URL (eg: https://dev.azure.com/my-company)
-d | --directory:
The directory where to store the backup archive.
-p | --pat: The Personnal Access Token (PAT) that you need to generate for your Azure Devops Account
-x|--dryrun: true/false - If you want to create a dummy file instead of cloning the repositories
-w|--projectwiki: true/false - If you want also backup the Wiki structure of the projects
-v|--verbose true/false - Verbose mode
If you don't want to install all those prerequisities or you want to isolate this process, you can run this task in a docker image.
The docker image and its documentation is available on Docker Hub (lionelpere/azure-devops-repository-backup)
docker run
-v ´YOUR_LOCAL_BACKUP_DIRECTORY`:/data
-e DEVOPS_PAT=`YOUR_PAT`
-e DEVOPS_ORG_URL=`YOUR_ORGANISATION_URL`
-e RETENTION_IN_DAYS=7 # Will delete all files older than 7 days in the backup directory
-e DRY_RUN=true # Will create a dummy file instead of cloning the repository
-e WIKI=true # If you want also backup the Wiki structure of the projects
lionelpere/azure-devops-repository-backup