Skip to content

Bash script to backup all the repositories of an Azure DevOps organization

License

Notifications You must be signed in to change notification settings

tomdess/azure-devops-repository-backup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

azure-devops-repository-backup

💡 Introduction

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).

Project

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

🔥 Bash Script

Prerequisite

  • 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
  • git, 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

💻 Launch script

version

Release notes

 ./backup-devops.sh [-h] -p PAT -d backup-dir -o organization -r retention [-v] [-x] [-w] -- backup Azure DevOps repositories
 where:
      -h  show this help text
      -p  personal access token (PAT) for Azure DevOps [REQUIRED]
      -d  backup directory path: the directory where to store the backup archive [REQUIRED]
      -o  Azure DevOps organization URL (e.g. https://dev.azure.com/organization) [REQUIRED]
      -r  retention days for backup files: how many days to keep the backup files [REQUIRED]
      -v  verbose mode [default is false]
      -x  dry run mode (no actual backup, only simulation) [default is false]
      -w  backup project wiki [default is true]

🐳 Use this in docker

  • Stable image version version
  • Based on script version: script

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)

💻 Launch script

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 

About

Bash script to backup all the repositories of an Azure DevOps organization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 96.6%
  • Dockerfile 3.4%