更新时间:2024-06-21 GMT+08:00

更新备份

功能介绍

根据备份id更改备份

调用方法

请参见如何调用API

URI

PUT /v3/{project_id}/backups/{backup_id}

表1 路径参数

参数

是否必选

参数类型

描述

backup_id

String

备份ID

project_id

String

项目ID

请求参数

表2 请求Body参数

参数

是否必选

参数类型

描述

backup

BackupUpdate object

更新请求参数体

表3 BackupUpdate

参数

是否必选

参数类型

描述

name

String

备份名称

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

backup

BackupResp object

备份副本

表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

请求示例

更改指定备份的备份名称。

PUT https://{endpoint}/v3/4229d7a45436489f8c3dc2b1d35d4987/backup/6df2b54c-dd62-4059-a07c-1b8f24f2725d

{
  "backup" : {
    "name" : "backup-name02"
  }
}

响应示例

状态码: 200

OK

{
  "backup" : {
    "provider_id" : "0daac4c5-6707-4851-97ba-169e36266b66",
    "checkpoint_id" : "8b0851a8-adf3-4f4c-a914-dead08bf9664",
    "enterprise_project_id" : 0,
    "vault_id" : "3b5816b5-f29c-4172-9d9a-76c719a659ce",
    "id" : "6df2b54c-dd62-4059-a07c-1b8f24f2725d",
    "resource_az" : "az1.dc1",
    "image_type" : "backup",
    "resource_id" : "94eba8b2-acc9-4d82-badc-127144cc5526",
    "resource_size" : 40,
    "children" : [ {
      "provider_id" : "0daac4c5-6707-4851-97ba-169e36266b66",
      "checkpoint_id" : "8b0851a8-adf3-4f4c-a914-dead08bf9664",
      "vault_id" : "3b5816b5-f29c-4172-9d9a-76c719a659ce",
      "id" : "5d822633-2bbf-4af8-a16e-5ab1c7705235",
      "image_type" : "backup",
      "resource_id" : "eccbcfdd-f843-4bbb-b2c0-a5ce861f9376",
      "resource_size" : 40,
      "children" : [ ],
      "parent_id" : "6df2b54c-dd62-4059-a07c-1b8f24f2725d",
      "extend_info" : {
        "auto_trigger" : true,
        "snapshot_id" : "5230a977-1a94-4092-8edd-519303a44cda",
        "bootable" : true,
        "encrypted" : true
      },
      "project_id" : "4229d7a45436489f8c3dc2b1d35d4987",
      "status" : "available",
      "resource_name" : "ecs-1f0f-0002",
      "replication_records" : [ ],
      "name" : "autobk_a843_ecs-1f0f-0002",
      "created_at" : "2019-05-10T07:59:59.451+00:00",
      "resource_type" : "OS::Cinder::Volume"
    } ],
    "extend_info" : {
      "auto_trigger" : true,
      "supported_restore_mode" : "backup",
      "contain_system_disk" : true,
      "support_lld" : true
    },
    "project_id" : "4229d7a45436489f8c3dc2b1d35d4987",
    "status" : "available",
    "resource_name" : "ecs-1f0f-0002",
    "description" : "backup_description",
    "replication_records" : [ ],
    "name" : "backup-name02",
    "created_at" : "2019-05-10T07:59:12.085+00:00",
    "resource_type" : "OS::Nova::Server"
  }
}

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
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 UpdateBackupSolution {

    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();
        UpdateBackupRequest request = new UpdateBackupRequest();
        BackupUpdateReq body = new BackupUpdateReq();
        BackupUpdate backupbody = new BackupUpdate();
        backupbody.withName("backup-name02");
        body.withBackup(backupbody);
        request.withBody(body);
        try {
            UpdateBackupResponse response = client.updateBackup(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
# 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 = UpdateBackupRequest()
        backupbody = BackupUpdate(
            name="backup-name02"
        )
        request.body = BackupUpdateReq(
            backup=backupbody
        )
        response = client.update_backup(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
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.UpdateBackupRequest{}
	nameBackup:= "backup-name02"
	backupbody := &model.BackupUpdate{
		Name: &nameBackup,
	}
	request.Body = &model.BackupUpdateReq{
		Backup: backupbody,
	}
	response, err := client.UpdateBackup(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

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

状态码

状态码

描述

200

OK

错误码

请参见错误码