elimisteve / azure-devops-repository-backup

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

azure-devops-repository-backup

💡 Introduction

Microsoft don't provide any built-in solution to backup Azure Devops Services.

They ask them to thrust the process as described in the Data Protection Overview page.

However most companies want to keep an on-premise backup of their code repositories in case of Disaster Recovery Plan (DRP).

Project

This project provides a bash script to backup all azure devops repositories of an Azure Devops Organization.

🔥 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

./backup.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
   -v|--verbose true/false - Verbose mode

🐳 Use this in docker

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
    lionelpere/azure-devops-repository-backup 

About

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

License:GNU General Public License v3.0


Languages

Language:Shell 87.4%Language:Dockerfile 12.6%