⚠️ Notice: This repository is maintained with assistance from Claude AI. All code changes are carefully reviewed by human maintainers before being merged to ensure quality and security.
Microsoft doesn't provide any built-in solution to backup Azure DevOps Services.
They recommend trusting 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 developed by Pacman1988.
- Bash shell (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
- Required packages:
git,jq,base64(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 [-h] -p PAT -d backup-dir -o organization -r retention [-v] [-x] [-w]Parameters:
-hshow this help text-ppersonal access token (PAT) for Azure DevOps [REQUIRED]-dbackup directory path: the directory where to store the backup archive [REQUIRED]-oAzure DevOps organization URL (e.g.https://dev.azure.com/organization) [REQUIRED]-rretention days for backup files: how many days to keep the backup files [REQUIRED]-vverbose mode [default: false]-xdry run mode (no actual backup, only simulation) [default: false]-wbackup project wiki [default: true]
If you don't want to install all those prerequisites or you want to isolate this process, you can run this task in a Docker image.
The Docker image and its documentation are 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 \
-e DRY_RUN=true \
-e WIKI=true \
lionelpere/azure-devops-repository-backupEnvironment Variables:
DEVOPS_PAT: Your Personal Access TokenDEVOPS_ORG_URL: Your Azure DevOps organization URLRETENTION_IN_DAYS: Number of days to keep backup files (e.g., 7)DRY_RUN: Set totrueto create dummy files instead of cloning repositoriesWIKI: Set totrueto also backup the Wiki structure of projects