1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure DevOpsで削除したリポジトリ復元

Posted at

概要

Azure DevOpsのRepoで削除したリポジトリに対して復元する手順を整理します。
削除したリポジトリは30日保存されるので、その日数を経過すると復元することはできないのでご注意ください。

個人用アクセストークン(PAT)作成

Microsoft Learnサイトで詳しく書いてありますので、そちらのサイトを参考して個人用アクセストークンを作成してください。
トークンは復旧作業で使いますので、とりあえず権限は「Full Access」、期間は「1日」で作成してください。
最終でトークンが現れたらメモしてください。

PAT作成ページ
https://dev.azure.com/{組織名}/_usersSettings/tokens

Postmanアプリ起動

REST APIを発行するので、Postmanをダウンロードしてください。

Postmanで認証設定

新しいHTTP Requestを作成し、「Authorization」タブメニューから下記のイメージで①の「Basic Auth」を選択します。UsernameとPasswordページが見えたら、②のようにUsernameは空欄、PasswordはメモしたPATを入力してください。

image.png

識別子取得

削除したリポジトリを復元するにはリポジトリの識別子(GUID)が必要なので、Azure DevOps REST APIを使って識別子を取得します。
PostmanのHTTPメソッドを「GET」にし、URLを下記のように設定してください。

識別子取得API
https://dev.azure.com/{組織名}/{プロジェクト名}/_apis/git/deletedrepositories?api-version=7.0

image.png

うまく取得できたら、Postmanの結果画面で削除したリポジトリのリストが見えます。識別子はid項目の値となります。

image.png

リポジトリ復元

最後の手順となります。
新しいHTTP Requestを作成しても、HTTPメソッドを「PATCH」にし、URLと「Body」の内容を下記のように設定してください。
ちなみにPostmanの仕様上、「Authorization」設定内容は引き続けられますので設定する必要がありません。

復元API
https://dev.azure.com/{組織名}/{プロジェクト名}/_apis/git/recycleBin/repositories/{識別子}?api-version=7.0
BODY内容
{
  "deleted":false
}

image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?