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

lionelpere/azure-devops-repository-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 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
  • 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 -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

🐳 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

Packages

No packages published