发送反馈
管理保留的备份
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了如何为 Cloud SQL 实例启用、停用和管理保留的备份。
保留的备份是指在删除实例后保留的备份。
这些备份包括在实例运行时创建的按需备份和自动备份。如需详细了解保留的备份的工作原理,请参阅保留的备份 。
您可以随时为实例启用保留的备份,只需修改实例 即可。您还可以将保留的备份恢复到新实例或现有实例 。
准备工作
如需在 Google Cloud 项目中管理保留的备份,您需要拥有以下权限:
任务
所需权限
列出备份
cloudsql.backupRuns.list
描述备份
cloudsql.backupRuns.get
更新备份
cloudsql.backupRuns.update
删除备份
cloudsql.backupRuns.delete
如需管理 Google Cloud 项目中的保留备份,您需要拥有以下权限:
操作
命令
所需权限
列出备份
gcloud sql backups list
cloudsql.backupRuns.list
描述备份
gcloud sql backups describe
cloudsql.backupRuns.get
更新备份
gcloud sql backups patch
cloudsql.backupRuns.update
删除备份
gcloud sql backups delete
cloudsql.backupRuns.delete
REST
如需管理 Google Cloud 项目中的保留备份,您需要拥有以下权限:
操作
方法
所需权限
列出备份
backups.listBackup
cloudsql.backupRuns.list
描述备份
backups.getBackup
cloudsql.backupRuns.get
更新备份
backups.updateBackup
cloudsql.backupRuns.update
删除备份
backups.deleteBackup
cloudsql.backupRuns.delete
为实例启用保留的备份
在创建实例 或修改现有实例 时,您可以在实例的数据保护 配置选项中启用保留的备份。
查看所有保留的备份的列表
您可以使用 Google Cloud 控制台、gcloud CLI 或 Cloud SQL API 查看 Google Cloud 项目保留的所有备份的列表。备份将包含备份名称、所属实例、备份类型和实例删除时间等详细信息。由于已删除实例的名称可以重复使用,因此我们建议使用 instance deletion time
字段来区分特定备份属于哪个实例。对于实时实例,此字段为空。
控制台
在 Google Cloud 控制台中,前往 Cloud SQL 备份 页面。
前往“Cloud SQL 备份”
点击您要查看其备份的已删除实例的名称。
您会看到所有保留的备份和最终备份的列表,以及已删除实例的备份详细信息。
gcloud
如需获取与 Google Cloud 项目关联的所有备份的列表,请使用 gcloud sql backups list 命令:
gcloud sql backups list
--project=PROJECT_ID
替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。
如需查看特定保留备份的详细信息,请使用 gcloud sql backups describe 命令:
gcloud sql backups describe BACKUP_NAME
--project=PROJECT_ID
替换以下内容:
BACKUP_NAME
:保留的备份的名称。
PROJECT_ID
:您的 Google Cloud 项目的 ID。
REST v1 获取所有保留返回的列表
您可以使用此示例获取与 Google Cloud 项目关联的所有保留备份的列表。如需查看此调用的完整参数列表,请参阅 backups.listBackups
页面。
在使用任何请求数据之前,请先进行以下替换:
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"state": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "This is a final backup.",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
查看保留的备份的详细信息
使用此示例可查看保留的备份的详细信息。如需查看此调用的完整参数列表,请参阅 backup.getBackup
页面。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID :项目 ID。
BACKUP_ID :备份 ID。您可以从运行上一个调用的输出中获取此 ID。
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID "
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"status": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "final backup",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
REST v1beta4 获取所有保留返回的列表
您可以使用此示例获取与 Google Cloud 项目关联的所有保留备份的列表。如需查看此调用的完整参数列表,请参阅 backups.listBackups
页面。
在使用任何请求数据之前,请先进行以下替换:
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"state": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "This is a final backup.",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
查看保留的备份的详细信息
使用此示例可查看保留的备份的详细信息。如需查看此调用的完整参数列表,请参阅 backups.getBackup
页面。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID :项目 ID。
BACKUP_ID :备份 ID。您可以从运行上一个调用的输出中获取此 ID。
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID "
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"status": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "final backup",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
更新保留的备份的说明
您可以随时更新保留的备份的说明,以便更轻松地识别备份。
控制台
在 Google Cloud 控制台中,前往 Cloud SQL 备份 页面。
前往“Cloud SQL 备份”
点击您要查看其备份的已删除实例的名称。
您会看到所有保留的备份和最终备份的列表,以及已删除实例的备份详细信息。
对于要更新的保留备份,请点击“更多操作”图标 ,然后选择修改说明 。
在修改备份说明 窗口中,更新备份的说明。
点击更新 。
gcloud 如需更新保留的备份的说明,请使用 gcloud sql backups patch 命令:
gcloud sql backups patch BACKUP_NAME
--description=BACKUP_DESCRIPTION
替换以下内容:
BACKUP_NAME
:保留的备份的名称。
BACKUP_DESCRIPTION
:您要添加到保留的备份中的新说明。
REST v1 获取所有保留返回的列表
您可以使用此示例获取与 Google Cloud 项目关联的所有保留备份的列表。如需查看此调用的完整参数列表,请参阅 backups.listBackups
页面。
在使用任何请求数据之前,请先进行以下替换:
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"state": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "This is a final backup.",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
更新说明
使用此示例更新保留的备份的说明。如需查看此调用的完整参数列表,请参阅 backups.updateBackup
页面。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID :项目 ID。
BACKUP_ID :备份 ID。您可以从运行上一个调用的输出中获取此 ID。
DESCRIPTION :最终备份的更新说明。
HTTP 方法和网址:
PATCH https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ?update_mask=description
请求 JSON 正文:
{
"backup": {
"description": DESCRIPTION ,
},
}
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ -d @request.json \ "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ?update_mask=description"
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method PATCH ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -InFile request.json ` -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ?update_mask=description" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ",
"status": "DONE",
"user": "user@example.com",
"insertTime": "2024-02-15T00:10:22.078Z",
"operationType": "UPDATE_BACKUP",
"name": "OPERATION_ID ",
"targetId": "BACKUP_ID ",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /operations/OPERATION_ID ",
"targetProject": "PROJECT_ID "
}
REST v1beta4 获取所有保留返回的列表
您可以使用此示例获取与 Google Cloud 项目关联的所有保留备份的列表。如需查看此调用的完整参数列表,请参阅 backups.listBackups
页面。
在使用任何请求数据之前,请先进行以下替换:
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"state": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "This is a final backup.",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
更新说明
使用此示例更新保留的备份的说明。如需查看此调用的完整参数列表,请参阅 backups.updateBackup
页面。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID :项目 ID。
BACKUP_ID :备份 ID。您可以从运行上一个调用的输出中获取此 ID。
DESCRIPTION :最终备份的更新说明。
HTTP 方法和网址:
PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ?update_mask=description
请求 JSON 正文:
{
"backup": {
"description": DESCRIPTION ,
},
}
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ -d @request.json \ "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ?update_mask=description"
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method PATCH ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -InFile request.json ` -Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ?update_mask=description" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ",
"status": "DONE",
"user": "user@example.com",
"insertTime": "2024-02-15T00:10:22.078Z",
"operationType": "UPDATE_BACKUP",
"name": "OPERATION_ID ",
"targetId": "BACKUP_ID ",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /operations/OPERATION_ID ",
"targetProject": "PROJECT_ID "
}
删除保留的备份
您可以使用 Google Cloud 控制台、gcloud CLI 或 Cloud SQL API 删除保留的备份。
控制台
在 Google Cloud 控制台中,前往 Cloud SQL 备份 页面。
前往“Cloud SQL 备份”
点击您要查看其备份的已删除实例的名称。
您会看到所有保留的备份和最终备份的列表,以及已删除实例的备份详细信息。
对于要删除的保留备份,请点击“更多操作”图标 ,然后选择删除 。
在删除备份 窗口中,输入已删除实例的名称,然后点击删除 。
REST v1 获取所有保留返回的列表
您可以使用此示例获取与 Google Cloud 项目关联的所有保留备份的列表。如需查看此调用的完整参数列表,请参阅 backups.listBackups
页面。
在使用任何请求数据之前,请先进行以下替换:
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"state": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "This is a final backup.",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
删除保留的备份
使用此示例删除保留的备份。如需查看此调用的完整参数列表,请参阅 backups.deleteBackup
页面。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID :项目 ID。
BACKUP_ID :备份 ID。您可以从运行上一个调用的输出中获取此 ID。
HTTP 方法和网址:
DELETE https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID "
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method DELETE ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /backups/BACKUP_ID ",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-21T22:43:37.981Z",
"operationType": "DELETE_BACKUP",
"name": "OPERATION_ID ",
"targetId": "BACKUP_ID ",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /operations/OPERATION_ID ",
"targetProject": "PROJECT_ID "
}
REST v1beta4 获取所有保留返回的列表
您可以使用此示例获取与 Google Cloud 项目关联的所有保留备份的列表。如需查看此调用的完整参数列表,请参阅 backups.listBackups
页面。
在使用任何请求数据之前,请先进行以下替换:
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method GET ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"name": "projects/PROJECT_ID /backups/BACKUP_ID ",
"kind": "sql#backup",
"state": "SUCCESSFUL",
"backupInterval": {
"startTime": "2020-01-21T11:25:33.858Z",
"endTime": "2020-01-21T11:26:18.663Z",
}
"type": "FINAL",
"instance": "INSTANCE_ID ",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ",
"location": "us"
"description": "This is a final backup.",
"backupKind": "SNAPSHOT",
"dataDiskSizeGB": "10",
"expiryTime": "2020-01-30T11:26:18.663Z",
"backup_run": "projects/PROJECT_ID /instances/INSTANCE_ID /backupRuns/BACKUP_RUN_ID ",
"satisfies_pzs": false,
"satisfies_pzi": false
}
删除保留的备份
使用此示例删除保留的备份。如需查看此调用的完整参数列表,请参阅 backups.deleteBackup
页面。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID :项目 ID。
BACKUP_ID :备份 ID。您可以从运行上一个调用的输出中获取此 ID。
HTTP 方法和网址:
DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID "
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method DELETE ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /backups/BACKUP_ID ",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-21T22:43:37.981Z",
"operationType": "DELETE_BACKUP",
"name": "OPERATION_ID ",
"targetId": "BACKUP_ID ",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /operations/OPERATION_ID ",
"targetProject": "PROJECT_ID "
}
后续步骤
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-03。
需要向我们提供更多信息?
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-04-03。"],[],[]]