-1

Team,

How to take backup of azure repo and is there any way to restore azure repository.

if someone deleted azure repo then how can restore this.

Thank you.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • Hi, How about the issue? Does the answer below resolve your question? If yes, you could [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) , so it could help other community members who get the same issues and we could archive this thread, thanks. – Vito Liu Jan 05 '21 at 09:37

2 Answers2

1

There is no way from VSTS web portal to restore a deleted repo, but two nice REST APIs are out there for you to manage soft-deleted git repo.

a. Create PAT

b. Retrieve soft-deleted git repositories from the recycle bin.

GET https://dev.azure.com/{organization}/{project}/_apis/git/recycleBin/repositories?api-version=5.0-preview.1

c. Recover a soft-deleted Git repository.

Note: Recently deleted repositories go into a soft-delete state for a period of time before they are hard deleted and become unrecoverable.

PATCH https://dev.azure.com/{organization}/{project}/_apis/git/recycleBin/repositories/{repositoryId}?api-version=5.0-preview.1

Request Body:

{
    "deleted": "false"
}

Result:

enter image description here

Vito Liu
  • 7,525
  • 1
  • 8
  • 17
1

Here are samples to work with Git Recycle Bin through PowerShell and Rest API:

  1. Get deleted repositories: GetRecycleBinRepositories.ps1
  2. Restore deleted repository (update $repoToRestore variable with needed name): RestoreRepositoryFromRecycleBin.ps1
Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31