示例1:创建弹性云服务器备份
约束限制
该接口以创建按需计费的存储库为例。
涉及接口
创建云服务器备份时,需要进行创建备份的容器存储库,将服务器或磁盘等资源挂载至存储库,为服务器或磁盘等资源创建备份。涉及的接口如下:
- 创建存储库:创建备份的容器。
- 为存储库添加保护资源:确定待备份云服务器或磁盘。
- 创建备份还原点:创建备份。
- 查询备份还原点:确认备份创建成功。
操作步骤
- 创建存储库。
- 创建简单配置的存储库。
- 接口相关信息
URI格式:POST /v3/{project_id}/vaults
详情请参见创建存储库。
- 请求示例
POST: https://{endpoint}/v3/{project_id}/vaults
{endpoint}信息请从地区和终端节点获取。
Body:
{ "vault": { "billing": { "cloud_type": "public", "consistent_level": "crash_consistent", "object_type": "server", "protect_type": "backup", "size": 200 }, "name": "my_vault", "resources": [] } }
- 响应示例
{ "vault": { "id": "ea7b8717-2543-478a-a92d-3ca7ee448f67", "name": "my_vault", "description": null, "resources": [], "provider_id": "0daac4c5-6707-4851-97ba-169e36266b66", "created_at": "2020-08-17T03:51:24.678916", "project_id": "0605767b5780d5762fc5c0118072a564", "enterprise_project_id": "0", "auto_bind": false, "bind_rules": {}, "user_id": "aa2999fa5ae640f28926f8fd79188934", "billing": { "allocated": 0, "cloud_type": "public", "consistent_level": "crash_consistent", "frozen_scene": null, "charging_mode": "post_paid", "order_id": null, "product_id": null, "protect_type": "backup", "object_type": "server", "spec_code": "vault.backup.server.normal", "used": 0, "storage_unit": null, "status": "available", "size": 200 }, "tags": [] } }
- 接口相关信息
- 创建包周期存储库并直接绑定服务器。
- 接口相关信息
URI格式:POST /v3/{project_id}/vaults
接口与步骤a保持一致。
- 请求示例
POST: https://{endpoint}/v3/{project_id}/vaults
{endpoint}信息请从地区和终端节点获取。
Body:
{ "vault": { "billing": { "cloud_type": "public", "consistent_level": "crash_consistent", "object_type": "server", "protect_type": "backup", "size": 100, "charging_mode": "pre_paid", "period_type": "month", "period_num": 1, "is_auto_renew": false, "is_auto_pay": false }, "description": "vault_description", "name": "vault_name", "resources": [{ "id": "97595625-198e-4e4d-879b-9d53f68ba551", "type": "OS::Nova::Server" }] } }
- 接口相关信息
- 记录响应消息体中存储库ID。
- 创建简单配置的存储库。
- 为存储库添加保护资源,将服务器/磁盘绑定到存储库中。
- 添加资源
- 接口相关信息
URI格式:POST /v3/{project_id}/vaults/{vault_id}/addresources
详情请参见添加资源。
- 请求示例
POST: https://{endpoint}/v3/0605767b5780d5762fc5c0118072a564 /vaults/ea7b8717-2543-478a-a92d-3ca7ee448f67/addresources
{endpoint}信息请从地区和终端节点获取。
Body:
{ "resources": [{ "id": "e8cc6bfd-d324-4b88-9109-9fb0ba70676f", "type": "OS::Nova::Server", "name": "server-4690-0002" }] }
- 响应示例
{ "add_resource_ids": [ "e8cc6bfd-d324-4b88-9109-9fb0ba70676f" ] }
- 接口相关信息
- 请求体中根据需要选择运行中且没有绑定存储库的云服务器ID。
- 添加资源
- 创建备份还原点。
- 创建备份还原点。
- 接口相关信息
URI格式:POST /v3/{project_id}/checkpoints
详情请参见创建备份还原点。
- 请求示例
POST: https://{endpoint}/v3/0605767b5780d5762fc5c0118072a564/checkpoints
{endpoint}信息请从地区和终端节点获取。
Body:
{ "checkpoint": { "parameters": { "auto_trigger": false, "description": "backupauto", "incremental": true, "name": "backup_auto", "resources": ["e8cc6bfd-d324-4b88-9109-9fb0ba70676f"] }, "vault_id": "ea7b8717-2543-478a-a92d-3ca7ee448f67" } }
- 响应示例
{ "checkpoint": { "id": "d9ce6924-d753-4132-bd16-a9f8838ea7d2", "project_id": "0605767b5780d5762fc5c0118072a564", "status": "protecting", "vault": { "id": "ea7b8717-2543-478a-a92d-3ca7ee448f67", "name": "my_vault", "resources": [ { "id": "e8cc6bfd-d324-4b88-9109-9fb0ba70676f", "type": "OS::Nova::Server", "name": "ecs-9f93-0002", "extra_info": "{}", "resource_size": "40", "backup_size": "0", "backup_count": "0", "protect_status": "available" } ], "skipped_resources": [] }, "created_at": "2020-08-17T06:49:06.307378", "extra_info": { "name": "backup_auto", "description": "backupauto", "retention_duration": -1 } } }
- 接口相关信息
- 记录响应消息体中备份还原点ID。
- 创建备份还原点。
- 确认服务器备份成功。
- 接口相关信息
URI格式:GET /v3/{project_id}/checkpoints/{checkpoint_id}
详情请参见查询备份还原点 。
{endpoint}信息请从地区和终端节点获取。
- 请求示例
GET: https://{endpoint}/v3/0605767b5780d5762fc5c0118072a564/checkpoints/d9ce6924-d753-4132-bd16-a9f8838ea7d2
- 响应示例
{ "checkpoint": { "id": "d9ce6924-d753-4132-bd16-a9f8838ea7d2", "project_id": "0605767b5780d5762fc5c0118072a564", "status": "available", "vault": null, "created_at": "2020-08-17T06:49:06.260790", "extra_info": null } }
- 接口相关信息