本繁體中文版使用機器翻譯,譯文僅供參考,若與英文版本牴觸,應以英文版本為準。

雲端備份API

貢獻者

透過Web UI提供的Cloud Backup功能也可透過RESTful API取得。

在這個功能區中定義了八種端點:Cloud Backup Service

  • 備份

  • 目錄

  • 雲端

  • 工作

  • 授權

  • 還原

  • 單一檔案層級還原(SFR)

  • 工作環境

快速入門

若要開始使用Cloud Backup API、您需要取得使用者權杖、您的BlueXP帳戶ID和BlueXP Connector ID。

撥打API呼叫時、您將在「授權」標頭中新增使用者權杖、並在X-agent-id標頭中新增BlueXP Connector ID。您應該在API中使用BlueXP帳戶ID。

步驟
  1. 從NetApp BlueXP網站取得使用者權杖。

    請務必從下列連結產生重新整理權杖:https://services.cloud.netapp.com/refresh-token/。重新整理權杖是一個英數字元字串、可用來產生使用者權杖。

    curl --location --request POST 'https://netapp-cloud-account.auth0.com/oauth/token?=' \
    --header 'Content-Type: application/json' \
    -d '{
        "grant_type": "refresh_token",
        "refresh_token": "JxaVHn9cGkX92aPVCkhat3zxxxxxwsC9qMl_pLHkZtsVA",
        "client_id": "Mu0V1ywgYteI6w1MbD15fKfVIUrNXGWC"
    }'
    附註 BlueXP網站的使用者權杖有到期日。API 回應包含「 Expire_in 」欄位、指出權杖過期的時間。若要重新整理權杖、您需要再次呼叫此API。
  2. 取得您的BlueXP帳戶ID。

    GET 'https://cloudmanager.cloud.netapp.com/tenancy/account' -H 'authority: cloudmanager.cloud.netapp.com'
    Header:
    -H 'accept: application/json'
    -H 'accept-language: en-GB,en;q=0.9'
    -H 'authorization: Bearer eyJhbGciOiJSUzI1NiIsInR………

    此API會傳回如下回應。您可以剖析*的輸出、以擷取帳戶ID。[帳戶PublicId]*。

    [{"accountPublicId":"account-i6vJXvZW","accountName":"rashidn","isSaas":true,"isGov":false,"isPrivatePreviewEnabled":false,"is3rdPartyServicesEnabled":false,"accountSerial":"96064469711530003565","userRole":"Role-1"}………
  3. 取得內含BlueXP Connector ID的X-agent-id。

    GET curl 'https://api.services.cloud.netapp.com/occm/list-occms/account-OOnAR4ZS?excludeStandalone=true&source=saas' \
    Header:
      -H 'authority: api.services.cloud.netapp.com' \
      -H 'accept: application/json' \
      -H 'accept-language: en-GB,en;q=0.9' \
      -H 'authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5…………

    此API會傳回如下回應。您可以剖析* occm.[0].[agent].[agentId]*的輸出來擷取代理程式ID。

    {"occms":[{"account":"account-OOnAR4ZS","accountName":"cbs","occm":"imEdsEW4HyYTFbt8ZcNKTKDF05jMIe6Z","agentId":"imEdsEW4HyYTFbt8ZcNKTKDF05jMIe6Z","status":"ready","occmName":"cbsgcpdevcntsg-asia","primaryCallbackUri":"http://34.93.197.21","manualOverrideUris":[],"automaticCallbackUris":["http://34.93.197.21","http://34.93.197.21/occmui","https://34.93.197.21","https://34.93.197.21/occmui","http://10.138.0.16","http://10.138.0.16/occmui","https://10.138.0.16","https://10.138.0.16/occmui","http://localhost","http://localhost/occmui","http://localhost:1337","http://localhost:1337/occmui","https://localhost","https://localhost/occmui","https://localhost:1337","https://localhost:1337/occmui"],"createDate":"1652120369286","agent":{"useDockerInfra":true,"network":"default","name":"cbsgcpdevcntsg-asia","agentId":"imEdsEW4HyYTFbt8ZcNKTKDF05jMIe6Zclients","provider":"gcp","systemId":"a3aa3578-bfee-4d16-9e10-

使用API的範例

以下範例顯示API呼叫、要求在工作環境中啟動Cloud Backup、新原則是在Azure雲端的東美2地區設定每日、每小時及每週標籤、並將天數設為180天之後歸檔。請注意、這只會在工作環境中啟用備份、但不會備份任何磁碟區。

如果您選擇「自動備份已啟用」:「true」、則系統中已存在的任何磁碟區都會備份、而且未來也會備份任何磁碟區。

API要求

您會發現我們使用的是BlueXP帳戶ID account-DpTFcxN3、BlueXP Connector ID iZwFFeVCZjWnzGlw8RgD0QQNANZvpP7Iclients`和使用者權杖 `Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5rSXlPVFUzUWpZek1E…y6nyhBjwkeMwHc4ValobjUmju2x0xUH48g 在此命令中。

curl --location --request POST 'https://cloudmanager.cloud.netapp.com/account/account-DpTFcxN3/providers/cloudmanager_cbs/api/v3/backup/working-environment/VsaWorkingEnvironment-99hPYEgk' \
--header 'x-agent-id: iZwFFeVCZjWnzGlw8RgD0QQNANZvpP7Iclients' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5rSXlPVFUzUWpZek1E…y6nyhBjwkeMwHc4ValobjUmju2x0xUH48g' \
--data-raw '{
    "provider":"AZURE",
    "backup-policy": {
      "archive-after-days": 180,
      "rule": [
        {
          "label": "hourly",
          "retention": "2"
        },
        {
          "label": "daily",
          "retention": "30"
        },
        {
          "label": "weekly",
          "retention": "52"
        }
      ]
    },
    "ip-space": "Default",
    "region": "eastus2",
    "azure": {
      "resource-group": "rn-test-backup-rg",
      "subscription": "3beb4dd0-25d4-464f-9bb0-303d7cf5c0c2"
    }
  }'
回應是您可以監控的工作ID。
{
    "job-id": "1b34b6f6-8f43-40fb-9a52-485b0dfe893a"
}
監控回應。
curl --location --request GET 'https://cloudmanager.cloud.netapp.com/account/account-DpTFcxN3/providers/cloudmanager_cbs/api/v1/job/1b34b6f6-8f43-40fb-9a52-485b0dfe893a' \
--header 'x-agent-id: iZwFFeVCZjWnzGlw8RgD0QQNANZvpP7Iclients' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5rSXlPVFUzUWpZek1E…hE9ss2NubK6wZRHUdSaORI7JvcOorUhJ8srqdiUiW6MvuGIFAQIh668of2M3dLbhVDBe8BBMtsa939UGnJx7Qz6Eg'
回應:
{
    "job": [
        {
            "id": "1b34b6f6-8f43-40fb-9a52-485b0dfe893a",
            "type": "backup-working-environment",
            "status": "PENDING",
            "error": "",
            "time": 1651852160000
        }
    ]
}
監控直到「狀態」為「已完成」。
{
    "job": [
        {
            "id": "1b34b6f6-8f43-40fb-9a52-485b0dfe893a",
            "type": "backup-working-environment",
            "status": "COMPLETED",
            "error": "",
            "time": 1651852160000
        }
    ]
}

API 參考

如需每個Cloud Backup API的文件、請參閱 https://docs.netapp.com/us-en/cloud-manager-automation/cbs/overview.html