Restore a project

Azure Boards | Azure DevOps Server 2020 | Azure DevOps Server 2019

You can restore a deleted project up to 28 days after it was deleted. This article shows you how.

Important

A project can only be restored if it was deleted from the Web or REST API.

Prerequisites

To restore a project, you must have the "delete project" permission set to Allow. To learn how to check your permissions, see View permissions.

To restore a project, you must delete project permissions and have the "delete project" permission set to Allow. To learn how to check your permissions, see View permissions.

Note

A recently deleted project is only viewable when there's a project that's been deleted from an organization within the last 28 days.

Restore project

  1. Sign in to your organization (https://dev.azure.com/{yourorganization}).

  2. Choose gear icon Organization settings.

    Choose the gear icon, Organization settings

  3. Select Overview, and then scroll down to "recently deleted projects."

    Screenshot that shows recently deleted projects.

  4. Highlight the project you want to restore, and then select Restore.

    Highlight the project, and then select Restore

Using REST API

Warning

If you're trying to restore a project with a name that's already taken, you need to rename the project before it can be restored. To rename the project, enter the following in the request body: "name":"new name"

  1. Open a browser window and enter a URL that uses the following form:

    http://ServerName:8080/tfs/DefaultCollection/ProjectName

    For example, to connect to the server named FabrikamPrime, enter: http://FabrikamPrime:8080/tfs/.

    The default Port is 8080. Specify the port number and directory for your server if defaults aren't used.

  2. Get a list of deleted projects using the following request:

    GET http://ServerName:8080/tfs/DefaultCollection/_apis/projects?stateFilter=deleted&api-version=5.0-preview.3
    
  3. Restore a deleted project using the following request:

    PATCH http://ServerName:8080/tfs/DefaultCollection/_apis/projects/{projectId}?api-version=5.0-preview.3
    

    Request body

    {
     "state" : "wellFormed"
    }
    

Using PowerShell

  1. Execute the following PowerShell script to get a list of deleted projects and make sure to update $collectionUrl.

    $collectionUrl = "https://localhost/defaultcollection" 
    (irm -Uri "$collectionUrl/_apis/projects?stateFilter=deleted&api-version=5.0-preview.3" -UseDefaultCredentials).value
    

    Something similar to the following screenshot appears: PowerShell script return example for deleted projects

  2. Use the following script to restore a project. Be sure to update $collectionUrl and $projectName.

    $collectionUrl = "https://localhost/defaultcollection"
    $projectName = 'Project1'
    $project = (irm -Uri "$collectionUrl/_apis/projects?stateFilter=deleted&api-version=5.0-preview.3" -UseDefaultCredentials).value | where {$_.name -eq $projectName}
    irm -Uri ($project.url + "?api-version=5.0-preview.3") -UseDefaultCredentials -Method PATCH -Body '{"state":"wellFormed"}' -ContentType 'application/json'
    

Your project and associated data are restored.