Edit

Share via


Restore a deleted wiki

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020

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, users might use the REST API to delete the Git repository associated with the wiki.

Note

Deleted repositories remain in the recycle bin for 30 days, after which they're 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 can view the wiki, including Stakeholders.
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
            }
    
  2. 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
    }
    
  3. 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 repository contents restore. If the wiki UI doesn't reappear automatically, publish the restored repo as a wiki or create a wiki via the Wiki REST API to re-register it with the project.

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 restores.

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 the 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

Reassociate a restored wiki

The recycle-bin restore recovers the Git repository (wiki pages and history) but doesn't always re-create the wiki registration or the file name association in the UI.

If the wiki doesn't appear after you restore the repo, do these steps:

  1. Confirm that the repo and branches exist in your project in Repos.
  2. Republish the repo as a wiki via the UI or recreate the wiki registration with the Wiki REST API to point to the restored repo.
  3. Verify the wiki appears in your project under Overview > Wiki, then check permissions, links, and any widgets that referenced the old wiki.

Note

The recycle-bin and some wiki-registration APIs are preview and can change—test in a nonproduction organization and use the api-version documented for your environment.

Next step