本文說明如何刪除 Secret 備份。刪除 Secret 備份後,備份和所有相關聯的資料都會永久刪除。刪除備份不會影響來源密鑰,或從備份還原的任何密鑰。
必要的角色
如要取得刪除 Secret 備份所需的權限,請要求管理員在專案、資料夾或組織中,授予您下列 IAM 角色:
- Secret Manager 編輯者 (
roles/secretmanager.editor) - Secret Manager 管理員 (
roles/secretmanager.admin)
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
這個預先定義的角色具備 secretmanager.backups.delete 權限,可刪除 Secret 備份。
刪除密鑰備份
如要刪除密鑰備份,請使用下列任一方法:
控制台
-
前往 Google Cloud 控制台的「Secret Manager」頁面。
-
前往「Backups」(備份) 分頁。
-
在清單中找出備份,然後按一下與該密鑰備份相關聯的 「Actions」(動作) 選單。在「Actions」(動作) 選單中,按一下「Delete backup」(刪除備份)。
-
在顯示的對話方塊中,輸入備份名稱進行確認,然後按一下「Delete backup」(刪除備份)。
REST
使用任何要求資料之前,請先修改下列項目的值:
- BACKUP_LOCATION:儲存備份的 Google Cloud 支援的地區。
- PROJECT_ID:儲存備份的 Google Cloud 專案 ID。
- BACKUP_ID:備份 ID。
HTTP 方法和網址:
DELETE https://secretmanager.BACKUP_LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/BACKUP_LOCATION/backups/BACKUP_ID
如要傳送要求,請選擇以下其中一個選項:
curl
執行下列指令:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://secretmanager.BACKUP_LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/BACKUP_LOCATION/backups/BACKUP_ID"
PowerShell
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://secretmanager.BACKUP_LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/BACKUP_LOCATION/backups/BACKUP_ID" | Select-Object -Expand Content
您應該會收到如下的 JSON 回覆:
{
"name": "projects/PROJECT_ID/locations/BACKUP_LOCATION/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.secretmanager.v1.OperationMetadata",
"createTime": "2026-03-25T08:24:13.153705Z",
"target": "projects/PROJECT_ID/locations/BACKUP_LOCATION/backups/BACKUP_ID",
"verb": "delete",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
}
後續步驟
- 瞭解如何還原備份。