本文說明如何查看 Secret 的備份清單。
必要的角色
如要取得列出備份所需的權限,請要求管理員在專案、資料夾或組織中,授予您下列 IAM 角色:
- Secret Manager 檢視者 (
roles/secretmanager.viewer) - Secret Manager 編輯者 (
roles/secretmanager.editor) - Secret Manager 管理員 (
roles/secretmanager.admin)
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
這些預先定義的角色具備列出備份所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:
所需權限
必須具備下列權限,才能列出備份:
-
secretmanager.backups.list -
secretmanager.backups.get
列出 Secret 的備份
如要列出密鑰的備份,請使用下列任一方法:
控制台
-
前往 Google Cloud 控制台的「Secret Manager」頁面。
-
選用:如要查看專案中的所有備份,請前往「Backups」(備份) 分頁。
-
如要查看特定 Secret 的備份,請按一下 Secret 名稱,前往 Secret 詳細資料頁面。
-
前往「Backups」(備份) 分頁,查看密鑰的備份。
REST
使用任何要求資料之前,請先修改下列項目的值:
- BACKUP_LOCATION:儲存備份的 Google Cloud 支援的地區。
- PROJECT_ID:儲存備份的 Google Cloud 專案 ID。
根據預設,這項要求會傳回專案中儲存在 BACKUP_LOCATION 的所有備份,包括已刪除 Secret 的備份。如要僅列出特定密鑰的備份,請新增 filter 查詢參數。例如:
?filter=sourceSecret="projects/PROJECT_ID/secrets/SECRET_ID"。
如要取得單一備份的詳細資料,請向 https://secretmanager.BACKUP_LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/BACKUP_LOCATION/backups/BACKUP_ID 傳送 GET 要求。
HTTP 方法和網址:
GET https://secretmanager.BACKUP_LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/BACKUP_LOCATION/backups
如要傳送要求,請選擇以下其中一個選項:
curl
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://secretmanager.BACKUP_LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/BACKUP_LOCATION/backups"
PowerShell
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://secretmanager.BACKUP_LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/BACKUP_LOCATION/backups" | Select-Object -Expand Content
您應該會收到如下的 JSON 回覆:
{
"backups": [
{
"name": "projects/PROJECT_ID/locations/BACKUP_LOCATION/backups/BACKUP_ID",
"sourceSecret": "projects/PROJECT_ID/secrets/SECRET_ID",
"createTime": "2026-03-25T08:24:13.153705Z",
"updateTime": "2026-03-25T08:24:45.912340Z",
"sourceSecretCreateTime": "2026-03-20T10:15:00.000000Z",
"versionCount": 1,
"state": "ACTIVE",
"etag": "\"16211daf5f29c5\""
}
]
}