Restore a deleted wiki

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

If a user accidentally deleted a provisioned (project) or published (code) wiki, you can restore it. Although there are no options in the UI to delete a wiki, a user might have used the REST API to delete the repository associated with the wiki.

Note

Deleted repositories remain in the recycle bin for 30 days, after which they are permanently deleted and can't be restored.

Prerequisites

Category Requirements
Project access Member of the project where the wiki is located. If you don't have access, request it from your project administrator. Anyone with access to the team project, including Stakeholders, can view the wiki.
Permissions - To add or edit wiki pages: Member of the Contributors group.
- To publish code as wiki: Create Repository permission. By default, this permission is set for members of the Project Administrators group.
Access levels At least Basic access.

Restore a complete wiki

Wikis, both project and code, are stored as repositories in your project in Azure DevOps. Complete the following steps to restore a complete wiki with REST API.

  1. Retrieve git repositories: List repositories.

    Use THE includeHidden=true parameter to see the wiki repositories.

GET https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/repositories?includeHidden=true&api-version=7.1-preview.1
        {
            "id": "978e3886-64a8-4b6f-96da-6afc2936b04b",
            "name": "fabrikamfiber.wiki",
            "url": https://dev.azure.com/christiechurch/052a83ac-af70-4194-b53f-df073e5f1786/_apis/git/repositories/978e3886-64a8-4b6f-96da-6afc2936b04b,
            "project": {
                "id": "052a83ac-af70-4194-b53f-df073e5f1786",
                "name": "fabrikamfiber",
                "url": https://dev.azure.com/christiechurch/_apis/projects/052a83ac-af70-4194-b53f-df073e5f1786,
                "state": "wellFormed",
                "revision": 421800049,
                "visibility": "organization",
                "lastUpdateTime": "2023-07-18T12:25:29.3Z"
            },
            "defaultBranch": "refs/heads/wikiMaster",
            "size": 193,
            "remoteUrl": https://christiechurch@dev.azure.com/christiechurch/fabrikamfiber/_git/fabrikamfiber.wiki,
            "sshUrl": git@ssh.dev.azure.com:v3/christiechurch/fabrikamfiber/fabrikamfiber.wiki,
            "webUrl": https://dev.azure.com/christiechurch/fabrikamfiber/_git/fabrikamfiber.wiki,
            "isDisabled": false,
            "isInMaintenance": false
        }
  1. Search the recycle bin for your repository.
GET https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/recycleBin/repositories?api-version=7.1-preview.1

When you find your repository, often named as .wiki, take note of the repo ID.

{
    "value": [
        {
            "id": "978e3886-64a8-4b6f-96da-6afc2936b04b",
            "name": "fabrikamfiber.wiki",
            "project": {
                "id": "052a83ac-af70-4194-b53f-df073e5f1786",
                "name": "fabrikamfiber",
                "url": https://dev.azure.com/christiechurch/_apis/projects/052a83ac-af70-4194-b53f-df073e5f1786,
                "state": "wellFormed",
                "revision": 421800049,
                "visibility": "organization",
                "lastUpdateTime": "2023-07-18T12:25:29.3Z"
            },
            "deletedBy": {
                "displayName": "Christie Church",
                "url": https://spsprodeus23.vssps.visualstudio.com/A1df9d653-bdfb-459b-a0c7-725052b2f944/_apis/Identities/0a0a4b55-9671-440d-87bf-26644f200d8a,
                "_links": {
                    "avatar": {
                        "href": https://dev.azure.com/christiechurch/_apis/GraphProfile/MemberAvatars/aad.MDY4MDk2OGQtYWU5OS03Y2M5LTgxZTEtNTBjMDk4ZTllZTlh
                    }
                },
                "id": "0a0a4b55-9671-440d-87bf-26644f200d8a",
                "uniqueName": christiechurch@fabrikam.com,
                "imageUrl": https://dev.azure.com/christiechurch/_api/_common/identityImage?id=0a0a4b55-9671-440d-87bf-26644f200d8a,
                "descriptor": "aad.MDY4MDk2OGQtYWU5OS03Y2M5LTgxZTEtNTBjMDk4ZTllZTlh"
            },
            "createdDate": "2023-07-18T12:23:55.64Z",
            "deletedDate": "2023-07-18T12:41:38.737Z"
        }
    ],
    "count": 1
}
  1. Restore the wiki from the repository recycle bin.
PATCH https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/recycleBin/repositories/978e3886-64a8-4b6f-96da-6afc2936b04b?api-version=7.1-preview.1
{
    "deleted": false
}

The wiki is restored.

Restore a wiki page

  1. Go to the URL for your repo: https://dev.azure.com/<OrgName>/<ProjectName>/_git/classicreleaseoption.wiki.

  2. Search for the history for the main branch, wikiMain.

  3. Find and select the commit that has the deleted files.

  4. Select More actions, and then Revert.

  5. Create and complete a pull request.

Your wiki page is restored.

Restore a wiki page with CLI

If you prefer command line options, do the following steps.

  1. Clone the wiki to your local machine.
  2. Search for the commit which has the deleted the page.
  3. Checkout that commit.
  4. Copy the page to make a new commit.

Your wiki page is restored.

Delete a repository

DELETE https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/repositories/052a83ac-af70-4194-b53f-df073e5f1786?api-version=7.1-preview.1

Next steps