All Products
Search
Document Center

Cloud Backup:Back up data across Alibaba Cloud accounts

Last Updated:Mar 04, 2024

You can use Cloud Backup to back up and restore data across Alibaba Cloud accounts. This enables enterprises to adopt centralized and unified policies for disaster recovery and compliance audit. This topic describes how to use an Alibaba Cloud account (Account A) to back up and restore the resources of another Alibaba Cloud account (Account B). To do this, you must create a Resource Access Management (RAM) role within Account B and authorize the service-linked role AliyunServiceRoleForHbrCrossAccountBackup of Account A to assume the RAM role to access the resources of Account B.

Background information

In a typical landing zone architecture, an enterprise has multiple Alibaba Cloud accounts for different departments, and the development or test environment needs to be isolated. However, the enterprise requires centralized and unified policies for disaster recovery and compliance audit.

For example, an enterprise has two Alibaba Cloud accounts: Account A for the production environment and Account B for the test environment. The enterprise needs to back up the resources of Account A and Account B in a unified way, restore the data of Account A to Account B for development and testing, and restore the data of Account B to Account A for version updates. In this case, the enterprise can create a backup account (Account C), or select Account A or Account B as the backup account. After the required permissions are granted to the backup account, the backup account can back up and restore the data of Account A and Account B.

image

How authorization works

The following steps show how to authorize Account A to back up the resources of Account B.

  1. Account A creates the AliyunServiceRoleForHbrCrossAccountBackup service-linked role. Cloud Backup uses the role to assume the RAM role of Account B to back up data.

  2. Account B creates a RAM role named hbrcrossrole and then performs the following steps:

    1. Grant precise permissions to the RAM role: Attach the system policy AliyunHBRRolePolicy to the RAM role hbrcrossrole. This policy grants the permissions to access the resources of Account B. The following script shows the detailed configuration of the system policy AliyunHBRRolePolicy:

      {
          "Version": "1",
          "Statement": [
              {
                  "Action": "bssapi:QueryAvailableInstances",
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": [
                      "nas:DescribeFileSystems",
                      "nas:CreateMountTargetSpecial",
                      "nas:DeleteMountTargetSpecial",
                      "nas:DescribeMountTargets",
                      "nas:DescribeAccessGroups"
                  ],
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": "cms:QueryMetricList",
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Effect": "Allow",
                  "Action": [
                      "ots:ListInstances",
                      "ots:ListTable",
                      "ots:CreateTable",
                      "ots:UpdateTable",
                      "ots:DescribeTable",
                      "ots:BatchWriteRow",
                      "ots:CreateTunnel",
                      "ots:DeleteTunnel",
                      "ots:ListTunnel",
                      "ots:DescribeTunnel",
                      "ots:ConsumeTunnel",
                      "ots:GetRange",
                      "ots:ListStream",
                      "ots:DescribeStream"
                  ],
                  "Resource": "*"
              },
              {
                  "Action": [
                      "oss:ListBuckets",
                      "oss:GetBucketInventory",
                      "oss:ListObjects",
                      "oss:HeadBucket",
                      "oss:GetBucket",
                      "oss:GetBucketAcl",
                      "oss:GetBucketLocation",
                      "oss:GetBucketInfo",
                      "oss:PutObject",
                      "oss:CopyObject",
                      "oss:GetObject",
                      "oss:AppendObject",
                      "oss:GetObjectMeta",
                      "oss:PutObjectACL",
                      "oss:GetObjectACL",
                      "oss:PutObjectTagging",
                      "oss:GetObjectTagging",
                      "oss:InitiateMultipartUpload",
                      "oss:UploadPart",
                      "oss:UploadPartCopy",
                      "oss:CompleteMultipartUpload",
                      "oss:AbortMultipartUpload",
                      "oss:ListMultipartUploads",
                      "oss:ListParts"
                  ],
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": "hcs-sgw:DescribeGateways",
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": [
                      "ecs:RunCommand",
                      "ecs:CreateCommand",
                      "ecs:InvokeCommand",
                      "ecs:DeleteCommand",
                      "ecs:DescribeCommands",
                      "ecs:StopInvocation",
                      "ecs:DescribeInvocationResults",
                      "ecs:DescribeCloudAssistantStatus",
                      "ecs:DescribeInstances",
                      "ecs:DescribeInstanceRamRole",
                      "ecs:DescribeInvocations",
                      "ecs:CreateSnapshotGroup",
                      "ecs:DescribeSnapshotGroups",
                      "ecs:DeleteSnapshotGroup"
                  ],
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": [
                      "ecs:DescribeSecurityGroups",
                      "ecs:DescribeImages",
                      "ecs:CreateImage",
                      "ecs:DeleteImage",
                      "ecs:DescribeSnapshots",
                      "ecs:CreateSnapshot",
                      "ecs:DeleteSnapshot",
                      "ecs:DescribeSnapshotLinks",
                      "ecs:DescribeAvailableResource",
                      "ecs:ModifyInstanceAttribute",
                      "ecs:CreateInstance",
                      "ecs:DeleteInstance",
                      "ecs:AllocatePublicIpAddress",
                      "ecs:CreateDisk",
                      "ecs:DescribeDisks",
                      "ecs:AttachDisk",
                      "ecs:DetachDisk",
                      "ecs:DeleteDisk",
                      "ecs:ResetDisk",
                      "ecs:StartInstance",
                      "ecs:StopInstance",
                      "ecs:ReplaceSystemDisk",
                      "ecs:ModifyResourceMeta"
                  ],
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": [
                      "ecs:AttachInstanceRamRole",
                      "ecs:DetachInstanceRamRole"
                  ],
                  "Resource": [
                      "acs:ecs:*:*:instance/*",
                      "acs:ram:*:*:role/aliyunecsaccessinghbrrole"
                  ],
                  "Effect": "Allow"
              },
              {
                  "Action": [
                      "ram:PassRole",
                      "ram:GetRole",
                      "ram:GetPolicy",
                      "ram:ListPoliciesForRole"
                  ],
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": [
                      "vpc:DescribeVpcs",
                      "vpc:DescribeVSwitches"
                  ],
                  "Resource": "*",
                  "Effect": "Allow"
              },
              {
                  "Action": "ram:DeleteServiceLinkedRole",
                  "Resource": "*",
                  "Effect": "Allow",
                  "Condition": {
                      "StringEquals": {
                          "ram:ServiceName": [
                              "otsbackup.hbr.aliyuncs.com",
                              "ossbackup.hbr.aliyuncs.com",
                              "ecsbackup.hbr.aliyuncs.com",
                              "nasbackup.hbr.aliyuncs.com",
                              "csgbackup.hbr.aliyuncs.com"
                          ]
                      }
                  }
              }
          ]
      }
    2. Modify the trust policy: Allow only the service-linked role AliyunServiceRoleForHbrCrossAccountBackup of Account A to assume the RAM role of Account B to access the resources of Account B.

  3. Log on to the Cloud Backup console with Account A and add Account B as the backup account. Set the Role Name parameter to hbrcrossrole, which is authorized to access the resources of Account B.

  4. In the Cloud Backup console, switch the logon account from Account A to Account B. Then, you can use Account A to back up and restore the resources of Account B.

Limits

Important

The cross-account backup feature can be used in the following scenarios: Elastic Compute Service (ECS) file backup, NAS backup, Object Storage Service (OSS) backup, Tablestore backup, and database backup. You can back up ECS instances across Alibaba Cloud accounts. However, after an ECS instance is backed up, you can restore the instance only to the source Alibaba Cloud account. For more information about the supported scenarios, see the Cloud Backup console.

Billing

You are not charged for using the cross-account backup feature of Cloud Backup. However, Account A that is used to back up and restore data pays for the backup and restoration fees. In ECS instance backup, Account B pays for the snapshot service fees and OSS request fees. For more information, see Billing methods and billable items.

Step 1: Assign the AliyunServiceRoleForHbrCrossAccountBackup service-linked role to Account A

To use Account A for cross-account backup and restoration, you must assign the AliyunServiceRoleForHbrCrossAccountBackup service-linked role to Account A.

  • Role name: AliyunServiceRoleForHbrCrossAccountBackup

  • Policy: AliyunServiceRolePolicyForHbrCrossAccountBackup

  • Permission description: The policy allows Cloud Backup to access the resources of other authorized accounts for cross-account backup and restoration.

Important

This operation is required only when you use the cross-account backup feature for the first time.

  1. Log on to the Cloud Backup console with Account A.

  2. In the left-side navigation pane, click Cross-Account Backup.

    In the dialog box that appears, assign the role as prompted.

  3. In the Service Access Authorization for Cloud Backup dialog box, click Confirm Authorization.

    For more information, see Service-linked roles for Cloud Backup.

Step 2: Create a RAM role for Account B

  1. Log on to the RAM console with Account B.

  2. In the left-side navigation pane, choose Identities > Roles.

  3. On the Roles page, click Create Role.

  4. In the Select Role Type step, select Alibaba Cloud Account as the trusted entity and click Next.

  5. In the Configure Role step, configure the parameters and click OK. The following table describes the parameters.

    Parameter

    Description

    RAM Role Name

    Enter a RAM role name, for example, hbrcrossrole.

    Note

    Enter a description for the RAM role.

    Select Trusted Alibaba Cloud Account

    Select Other Alibaba Cloud Account. Then, enter the ID of Account A in the text box.

    Note

    You can view the ID of an Alibaba Cloud account on the Security Settings page.

  6. In the Finish step, click Close.

Step 3: Grant permissions to the RAM role

After you create a RAM role, the RAM role does not have permissions. Before Account A can assume the RAM role to access the resources of Account B, you must attach the required system policy or custom policy to the RAM role. You can attach one of the following policies to the RAM role:

  • AdministratorAccess: grants the permissions to manage all cloud resources.

  • AliyunHBRRolePolicy: grants the permissions defined in the system policy of Cloud Backup. You must attach the system policy by clicking Precise Permission in the RAM console.

AliyunHBRRolePolicy is used in this example.

  1. Log on to the RAM console with Account B.

  2. In the left-side navigation pane, choose Identities > Roles.

  3. Find the created RAM role, for example, hbrcrossrole, and click the role name to go to the details page of the RAM role.

  4. On the Permissions tab, click Precise Permission.

  5. In the Precise Permission panel, set Type to System Policy, enter AliyunHBRRolePolicy in the Policy Name field, and then click OK.

  6. The system prompts that the exact authorization is successful. Click Close.

  7. Modify the trust policy of the RAM role.

    1. On the details page of the RAM role, click the Trust Policy tab.

    2. Click Edit Trust Policy.

    3. In the script editor, copy the following code to the text box. Replace Account ID with the ID of Account A.

      The following policy allows Account A to obtain a temporary token to manage the cloud resources of Account B in the Cloud Backup console.

      Note

      You can view the ID of an Alibaba Cloud account on the Security Settings page.

      {
       "Statement": [
           {
               "Action": "sts:AssumeRole",
               "Effect": "Allow",
               "Principal": {
                   "RAM": [
                       "acs:ram::Account ID:role/AliyunServiceRoleForHbrCrossAccountBackup"
                   ]
               }
           }
       ],
       "Version": "1"
      }
    4. Click Save trust policy document. The configuration is complete.

Step 4: Add a backup account

  1. Log on to the Cloud Backup console with Account A.

  2. In the top navigation bar, select a region.

    Important

    If you want to back up the ECS files, NAS files, OSS objects, Tablestore tables, or ECS instances that are owned by Account B in Region C, select Region C. In other words, add a backup account in the region where the resources to be backed up are located.

  3. In the left-side navigation pane, click Cross-Account Backup.

  4. On the Cross-Account Backup page, click Add Backup Account.

  5. In the Add Backup Account dialog box, configure the following parameters and click OK.

    image.png

    Parameter

    Description

    Alibaba Cloud Account ID

    Enter the ID of your Alibaba Cloud account. In this example, enter the ID of Account B.

    Note

    You can view the ID of an Alibaba Cloud account on the Security Settings page.

    Role Name

    Enter the name of the created RAM role. In this example, enter hbrcrossrole, which is created in Step 2: Create a RAM role for Account B.

    Important

    You can click Check Permissions to check whether the authorization configurations are correct. If an error is prompted, modify the authorization configurations and try again. If the check is passed, the following message appears: You are authorized to access the resources of this role.

    Account Alias

    Enter an account alias to help you manage the backup account.

    After the backup account is created, it is displayed on the Cross-Account Backup page.

    zhanghao

Step 5: Perform cross-account backup

After the backup account is created, you can log on to the Cloud Backup console with Account A, switch the logon account to Account B, and then back up the data sources of Account B.

  1. Log on to the Cloud Backup console with Account A.

  2. In the top navigation bar, select the region where the resources that you want to back up reside.

  3. Click Logon Account and select Account B.image.png

  4. In the left-side navigation pane, select a backup feature to perform cross-account backup.

    Important

    The cross-account backup feature can be used in the following scenarios: ECS file backup, NAS backup, OSS backup, Tablestore backup, and database backup. You can back up ECS instances across Alibaba Cloud accounts. However, after an ECS instance is backed up, you can restore the instance only to the source Alibaba Cloud account. For more information about the supported scenarios, see the Cloud Backup console.

    For example, if you select ECS File Backup, you can view the ECS assets of Account B in the ECS instance list. After data backup is complete, the data sources of Account B are backed up to the backup vaults of Account A.

Step 6: Restore data across accounts

After you back up the data sources of Account B by using Account A, the backup vaults store the backup data of Account A and Account B. The backup vaults are common backup vaults. You can restore data from any historical backup point in the backup vaults to Account A or Account B.

  1. Switch the account.

    The backup vaults are common backup vaults. Both Account A and Account B can restore data by using historical backup points in the backup vaults. Switch to the account whose data you want to restore.

  2. Creates a restore job. To create a restore job for different data sources, see the following topics:

Disable cross-account backup

Important
  • After you disable the cross-account backup feature for Account A and Account B, Account A can no longer back up data sources from Account B. Evaluate your business requirements and proceed with caution.

  • We recommend that you do not disable the cross-account backup feature for other accounts. If you do not perform backup and restoration operations, no additional fees are incurred.

  • After you disable the cross-account backup feature, the backup data is still stored in the backup vaults of Cloud Backup. You are still charged for the storage usage of backup vaults. For more information about how to stop being billed, see How do I stop being billed for Cloud Backup? Data cannot be restored after its backup is deleted.

  1. Switch to Account B. Find the data sources, uninstall the Cloud Backup client (if any), unregister the associated instances, and delete the backup vault. For more information, see How do I stop being billed for Cloud Backup?

  2. Switch to Account A. On the Cross-Account Backup page in the Cloud Backup console, delete Account B.image.png

  3. Delete the RAM role that is created for Account B.

    1. Log on to the RAM console with Account B.

    2. In the left-side navigation pane, choose Identities > Roles.

    3. Find the RAM role created for Account B, for example, hbrcrossrole. Click Delete Role in the Actions column.

References