文档首页/ 云备份 CBR/ API参考/ API/ 备份/ 查询所有备份
更新时间:2024-06-20 GMT+08:00
分享

查询所有备份

功能介绍

查询所有副本

调用方法

请参见如何调用API

URI

GET /v3/{project_id}/backups

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID

表2 Query参数

参数

是否必选

参数类型

描述

checkpoint_id

String

还原点ID

dec

Boolean

专属云 (专属云场景使用,非专属云场景不生效)

end_time

String

备份产生时间范围的结束时间,格式为%YYYY-%mm-%ddT%HH:%MM:%SSZ,例如2018-02-01T12:00:00Z

enterprise_project_id

String

企业项目id或all_granted_eps,all_granted_eps表示查询用户有权限的所有企业项目id

image_type

String

备份类型。取值为backup和replication。

incremental

Boolean

是否是增备

缺省值:false

limit

Integer

每页显示的条目数量,正整数

marker

String

上一次查询最后一条的id

member_status

String

共享状态

name

String

名称

offset

Integer

偏移值,正整数

own_type

String

持有类型,私有的private/共享的shared/全部all_granted,默认只查询private。

缺省值:private

parent_id

String

父备份ID

resource_az

String

支持按az来过滤

resource_id

String

资源ID

resource_name

String

资源名称

resource_type

String

资源类型: OS::Nova::Server, OS::Cinder::Volume, OS::Ironic::BareMetalServer, OS::Native::Server, OS::Sfs::Turbo, OS::Workspace::DesktopV2

show_replication

Boolean

是否返回复制记录

缺省值:false

sort

String

sort的内容为一组由逗号分隔的属性及可选排序方向组成,形如<key1>[:<direction>],<key2>[:<direction>],其中direction的取值为asc (升序) 或 desc (降序),如没有传入direction参数,默认为降序,sort内容的长度限制为255个字符。key取值范围:[created_at,updated_at,name,status,protected_at,id]

start_time

String

备份产生时间范围的开始时间,格式为%YYYY-%mm-%ddT%HH:%MM:%SSZ,例如2018-02-01T12:00:00Z

status

String

状态。 调用API时,支持通过传多个status值进行过滤。例如:status=available&status=error

used_percent

String

根据存储库使用率过滤备份,取值范围 [1, 100],含1和100。例如,used_percent=80,表示筛选所属存储库使用率大于等于80%的所有备份。

vault_id

String

存储库ID

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

backups

Array of BackupResp objects

备份列表

count

Integer

备份个数

offset

Integer

偏移量,表示从此偏移量开始查询

最小值:0

缺省值:0

limit

Integer

每页显示的条目数量

最小值:1

最大值:1000

缺省值:1000

表5 BackupResp

参数

参数类型

描述

checkpoint_id

String

还原点ID

created_at

String

创建时间,例如:"2020-02-05T10:38:34.209782"

description

String

备份描述

expired_at

String

过期时间,例如:"2020-02-05T10:38:34.209782"

extend_info

BackupExtendInfo object

扩展信息

id

String

备份ID

image_type

String

备份类型。取值为backup和replication。

name

String

备份名称

parent_id

String

父备份ID

project_id

String

项目ID

protected_at

String

备份时间

resource_az

String

资源可用区

resource_id

String

资源ID

resource_name

String

资源名称

resource_size

Integer

资源大小,单位为GB

resource_type

String

资源类型: OS::Nova::Server, OS::Cinder::Volume, OS::Ironic::BareMetalServer, OS::Native::Server, OS::Sfs::Turbo, OS::Workspace::DesktopV2

status

String

备份状态

  • available: 可用

  • protecting: 保护中

  • deleting: 删除中

  • restoring: 恢复中

  • error: 异常

  • waiting_protect: 等待保护

  • waiting_delete: 等待删除

  • waiting_restore: 等待恢复

updated_at

String

更新时间,例如:"2020-02-05T10:38:34.209782"

vault_id

String

存储库ID

replication_records

Array of ReplicationRecordGet objects

复制记录

enterprise_project_id

String

企业项目id,默认为‘0’。

provider_id

String

备份提供商ID,用于区分备份对象。当前取值包含: 0daac4c5-6707-4851-97ba-169e36266b66,该值代表备份对象为云服务器。d1603440-187d-4516-af25-121250c7cc97,该值代表备份对象为云硬盘。3f3c3220-245c-4805-b811-758870015881, 该值代表备份对象为SFS Turbo。a13639de-00be-4e94-af30-26912d75e4a2,该值代表备份对象为混合云VMware备份。

children

Array of BackupResp objects

子副本列表

incremental

Boolean

是否是增备

表6 BackupExtendInfo

参数

参数类型

描述

auto_trigger

Boolean

是否是自动生成的备份副本

bootable

Boolean

是否系统盘备份

snapshot_id

String

卷备份副本的快照id

support_lld

Boolean

是否支持lazyloading快速恢复

supported_restore_mode

String

备份支持恢复的方式

  • na: 备份不支持直接恢复,只支持备份创建新资源等操作。

  • backup: 备份支持通过云服务器上硬盘的备份进行恢复。

  • snapshot: 备份此时已经支持创建整机镜像。

缺省值:na

os_images_data

Array of ImageData objects

备份注册镜像ID列表

contain_system_disk

Boolean

整机备份是否包含系统盘

encrypted

Boolean

是否加密

system_disk

Boolean

是否是系统盘

is_multi_az

Boolean

备份类型是否为多AZ

缺省值:false

表7 ImageData

参数

参数类型

描述

image_id

String

镜像ID

表8 ReplicationRecordGet

参数

参数类型

描述

created_at

String

复制的开始时间

destination_backup_id

String

复制的目的备份ID

destination_checkpoint_id

String

复制的目的备份记录ID

destination_project_id

String

复制的目标项目ID

destination_region

String

复制的目标区域

destination_vault_id

String

目标存储库ID

extra_info

ReplicationRecordsExtraInfo object

复制附加信息

id

String

复制记录ID

source_backup_id

String

复制的源备份ID

source_checkpoint_id

String

复制的源备份记录ID

source_project_id

String

复制的源项目ID

source_region

String

复制的源区域

status

String

复制的状态

  • replicating: 复制中

  • success: 成功

  • fail: 失败

  • skip: 跳过

  • waiting_replicate: 等待复制

vault_id

String

备份所在的存储库ID

表9 ReplicationRecordsExtraInfo

参数

参数类型

描述

progress

Integer

复制进度

fail_code

String

失败错误码,成功时为空

fail_reason

String

错误原因

auto_trigger

Boolean

是否为自动调度复制

destinatio_vault_id

String

目标端的存储库id

请求示例

查询所有备份副本。

GET https://{endpoint}/v3/{project_id}/backups

响应示例

状态码: 200

OK

{
  "count" : 2,
  "backups" : [ {
    "provider_id" : "0daac4c5-6707-4851-97ba-169e36266b66",
    "checkpoint_id" : "1fced58b-2a31-4851-bcbb-96216f83ce99",
    "updated_at" : "2020-02-21T07:07:25.114+00:00",
    "vault_id" : "cca85ea5-00a4-418d-9222-bd83985bc515",
    "id" : "b1c4afd9-e7a6-4888-9010-c2bac3aa7910",
    "resource_az" : "br-iaas-odin1a",
    "image_type" : "backup",
    "resource_id" : "1a503932-ee8f-4dd5-8248-8dfb57e584c5",
    "resource_size" : 40,
    "children" : [ ],
    "extend_info" : {
      "auto_trigger" : true,
      "supported_restore_mode" : "backup",
      "contain_system_disk" : true,
      "support_lld" : true,
      "system_disk" : false
    },
    "project_id" : "0605767b5780d5762fc5c0118072a564",
    "status" : "available",
    "resource_name" : "test001-02",
    "description" : "",
    "expired_at" : "2020-05-21T07:00:54.060+00:00",
    "name" : "autobk_b629",
    "created_at" : "2020-02-21T07:00:54.065+00:00",
    "resource_type" : "OS::Nova::Server"
  }, {
    "provider_id" : "d1603440-187d-4516-af25-121250c7cc97",
    "checkpoint_id" : "f64c351f-769f-4c04-8806-fd90a59e9b12",
    "updated_at" : "2020-02-21T07:09:37.767+00:00",
    "vault_id" : "79bd9daa-884f-4f84-b8fe-235d58cd927d",
    "id" : "5606aab5-2dc2-4498-8144-dc848d099af5",
    "resource_az" : "br-iaas-odin1a",
    "image_type" : "backup",
    "resource_id" : "54f7ccbc-072f-4ec5-a7b7-b24dabdb4539",
    "resource_size" : 40,
    "children" : [ ],
    "extend_info" : {
      "auto_trigger" : true,
      "snapshot_id" : "e3def9a8-e4b4-4c12-b132-f4ba8ce9a34f",
      "bootable" : true,
      "support_lld" : true,
      "encrypted" : false,
      "system_disk" : false
    },
    "project_id" : "0605767b5780d5762fc5c0118072a564",
    "status" : "available",
    "resource_name" : "qsy_000",
    "description" : "",
    "expired_at" : "2020-03-22T07:00:34.878+00:00",
    "name" : "autobk_6809",
    "created_at" : "2020-02-21T07:00:34.882+00:00",
    "resource_type" : "OS::Cinder::Volume"
  } ]
}

SDK代码示例

SDK代码示例如下。

Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.cbr.v1.region.CbrRegion;
import com.huaweicloud.sdk.cbr.v1.*;
import com.huaweicloud.sdk.cbr.v1.model.*;


public class ListBackupsSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        CbrClient client = CbrClient.newBuilder()
                .withCredential(auth)
                .withRegion(CbrRegion.valueOf("<YOUR REGION>"))
                .build();
        ListBackupsRequest request = new ListBackupsRequest();
        request.withCheckpointId("<checkpoint_id>");
        request.withDec(<dec>);
        request.withEndTime("<end_time>");
        request.withImageType(ListBackupsRequest.ImageTypeEnum.fromValue("<image_type>"));
        request.withLimit(<limit>);
        request.withMarker("<marker>");
        request.withName("<name>");
        request.withOffset(<offset>);
        request.withResourceAz("<resource_az>");
        request.withResourceId("<resource_id>");
        request.withResourceName("<resource_name>");
        request.withResourceType(ListBackupsRequest.ResourceTypeEnum.fromValue("<resource_type>"));
        request.withSort("<sort>");
        request.withStartTime("<start_time>");
        request.withStatus(ListBackupsRequest.StatusEnum.fromValue("<status>"));
        request.withVaultId("<vault_id>");
        request.withEnterpriseProjectId("<enterprise_project_id>");
        request.withOwnType(ListBackupsRequest.OwnTypeEnum.fromValue("<own_type>"));
        request.withMemberStatus(ListBackupsRequest.MemberStatusEnum.fromValue("<member_status>"));
        request.withParentId("<parent_id>");
        request.withUsedPercent("<used_percent>");
        request.withShowReplication(<show_replication>);
        request.withIncremental(<incremental>);
        try {
            ListBackupsResponse response = client.listBackups(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcbr.v1.region.cbr_region import CbrRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcbr.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = CbrClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CbrRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListBackupsRequest()
        request.checkpoint_id = "<checkpoint_id>"
        request.dec = <Dec>
        request.end_time = "<end_time>"
        request.image_type = "<image_type>"
        request.limit = <limit>
        request.marker = "<marker>"
        request.name = "<name>"
        request.offset = <offset>
        request.resource_az = "<resource_az>"
        request.resource_id = "<resource_id>"
        request.resource_name = "<resource_name>"
        request.resource_type = "<resource_type>"
        request.sort = "<sort>"
        request.start_time = "<start_time>"
        request.status = "<status>"
        request.vault_id = "<vault_id>"
        request.enterprise_project_id = "<enterprise_project_id>"
        request.own_type = "<own_type>"
        request.member_status = "<member_status>"
        request.parent_id = "<parent_id>"
        request.used_percent = "<used_percent>"
        request.show_replication = <ShowReplication>
        request.incremental = <Incremental>
        response = client.list_backups(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    cbr "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cbr.NewCbrClient(
        cbr.CbrClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListBackupsRequest{}
	checkpointIdRequest:= "<checkpoint_id>"
	request.CheckpointId = &checkpointIdRequest
	decRequest:= <dec>
	request.Dec = &decRequest
	endTimeRequest:= "<end_time>"
	request.EndTime = &endTimeRequest
	imageTypeRequest:= model.GetListBackupsRequestImageTypeEnum().<IMAGE_TYPE>
	request.ImageType = &imageTypeRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	markerRequest:= "<marker>"
	request.Marker = &markerRequest
	nameRequest:= "<name>"
	request.Name = &nameRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	resourceAzRequest:= "<resource_az>"
	request.ResourceAz = &resourceAzRequest
	resourceIdRequest:= "<resource_id>"
	request.ResourceId = &resourceIdRequest
	resourceNameRequest:= "<resource_name>"
	request.ResourceName = &resourceNameRequest
	resourceTypeRequest:= model.GetListBackupsRequestResourceTypeEnum().<RESOURCE_TYPE>
	request.ResourceType = &resourceTypeRequest
	sortRequest:= "<sort>"
	request.Sort = &sortRequest
	startTimeRequest:= "<start_time>"
	request.StartTime = &startTimeRequest
	statusRequest:= model.GetListBackupsRequestStatusEnum().<STATUS>
	request.Status = &statusRequest
	vaultIdRequest:= "<vault_id>"
	request.VaultId = &vaultIdRequest
	enterpriseProjectIdRequest:= "<enterprise_project_id>"
	request.EnterpriseProjectId = &enterpriseProjectIdRequest
	ownTypeRequest:= model.GetListBackupsRequestOwnTypeEnum().<OWN_TYPE>
	request.OwnType = &ownTypeRequest
	memberStatusRequest:= model.GetListBackupsRequestMemberStatusEnum().<MEMBER_STATUS>
	request.MemberStatus = &memberStatusRequest
	parentIdRequest:= "<parent_id>"
	request.ParentId = &parentIdRequest
	usedPercentRequest:= "<used_percent>"
	request.UsedPercent = &usedPercentRequest
	showReplicationRequest:= <show_replication>
	request.ShowReplication = &showReplicationRequest
	incrementalRequest:= <incremental>
	request.Incremental = &incrementalRequest
	response, err := client.ListBackups(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

错误码

请参见错误码

相关文档