Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS-ECS-RestoreDataWithSnapshot

Última atualização: Jun 28, 2026

Nome do modelo

ACS-ECS-RestoreDataWithSnapshot: Restaurar dados com um snapshot

Executar agora

Descrição do modelo

Cria um disco em nuvem temporário a partir de um snapshot para restaurar dados.

Tipo de modelo

Automation

Proprietário

Alibaba Cloud

Parâmetros de entrada

Nome do parâmetro

Descrição

Tipo

Obrigatório

Valor padrão

Restrições

regionId

O ID da região.

String

Sim

snapshotId

O ID do snapshot.

String

Sim

instanceId

O ID da instância.

String

Sim

retainTempDisk

Indica se o disco em nuvem temporário deve ser mantido.

Boolean

Não

False

workingDir

O diretório de trabalho.

String

Não

/root

OOSAssumeRole

A função RAM assumida pelo OOS.

String

Não

""

Parâmetros de resposta

Nome do parâmetro

Descrição

Tipo

mountDiskOutputs

List

unmountDiskOutputs

List

Política de acesso necessária para executar este modelo

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:AttachDisk",
                "ecs:CreateDisk",
                "ecs:DeleteDisk",
                "ecs:DescribeDisks",
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:DetachDisk",
                "ecs:ModifyDiskAttribute",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Detalhes

Detalhes do ACS-ECS-RestoreDataWithSnapshot

Conteúdo do modelo

FormatVersion: OOS-2019-06-01
Description:
  en: Use a snapshot to create a temporary cloud disk to restore data.
  zh-cn: Use a snapshot to create a temporary cloud disk to restore data.
  name-en: ACS-ECS-RestoreDataWithSnapshot
  name-zh-cn: Restore data with a snapshot
  categories:
    - instance_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: Region ID
    AssociationProperty: RegionId
  snapshotId:
    Type: String
    Label:
      en: SnapshotId
      zh-cn: Snapshot ID
    AssociationProperty: ALIYUN::ECS::Snapshot::SnapshotId
  instanceId:
    Type: String
    Label:
      en: InstanceId
      zh-cn: Instance ID
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: regionId
      Status: Running
  retainTempDisk:
    Type: Boolean
    Label:
      en: RetainTempDisk
      zh-cn: Retain Temporary Cloud Disk
    Description:
      en: 'Whether to retain the temporary cloud disk. If you want to retain the temporary cloud disk, select Yes to use it as a common cloud disk. You can manually unmount and release the cloud disk when it is not needed.'
      zh-cn: 'Specifies whether to retain the temporary cloud disk. If you want to retain the temporary cloud disk, select Yes. The disk can then be used as a basic cloud disk. You can manually unmount and release the cloud disk when it is no longer needed.'
    Default: false
  workingDir:
    Type: String
    Label:
      en: WorkingDir
      zh-cn: Working Directory
    Description:
      en: 'Root permission is required to execute this script. Linux instances: under the home directory of the administrator (root user): /root. Windows instances: do not support OOS script execution. Manually create a temporary cloud disk to recover data.'
      zh-cn: 'Root permissions are required to execute this script. For Linux instances, the default directory is the home directory of the administrator (root user): /root. Windows instances do not support OOS script execution. Manually create a temporary cloud disk to recover data.'
    Default: /root
  OOSAssumeRole:
    Type: String
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role that OOS assumes
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: checkInstanceStatus
    Action: ACS::CheckFor
    Description:
      en: Check the instance status.
      zh-cn: Check the instance status.
    Properties:
      Service: ECS
      API: DescribeInstances
      DesiredValues:
        - Running
      Parameters:
        RegionId: '{{ regionId }}'
        InstanceIds:
          - '{{ instanceId }} '
      PropertySelector: Instances.Instance[].Status
    Outputs:
      zoneId:
        Type: String
        ValueSelector: Instances.Instance[].ZoneId
  - Name: createDiskBySnapshot
    Action: ACS::ExecuteApi
    Description:
      en: Use the snapshot to create a temporary cloud disk.
      zh-cn: Use the snapshot to create a temporary cloud disk.
    Properties:
      Service: ECS
      API: CreateDisk
      Parameters:
        RegionId: '{{ regionId }}'
        ZoneId: '{{ checkInstanceStatus.zoneId }}'
        SnapshotId: '{{ snapshotId}}'
        DiskName: TempDiskFrom-{{ snapshotId }}
        DiskCategory: cloud_essd
    Outputs:
      diskId:
        Type: String
        ValueSelector: .DiskId
  - Name: modifyDiskAttribute
    Action: ACS::ExecuteApi
    Description:
      en: Modify the attributes of the temporary cloud disk to be released with the instance.
      zh-cn: Modify the attributes of the temporary cloud disk to be released with the instance.
    Properties:
      Service: ECS
      API: ModifyDiskAttribute
      Parameters:
        DiskId: '{{ createDiskBySnapshot.diskId }}'
        DeleteWithInstance: true
  - Name: attachDisk
    Action: ACS::ExecuteApi
    Description:
      en: Attach the temporary cloud disk to the ECS instance.
      zh-cn: Attach the temporary cloud disk to the ECS instance.
    Properties:
      Service: ECS
      API: AttachDisk
      Parameters:
        InstanceId: '{{ instanceId }}'
        DiskId: '{{ createDiskBySnapshot.diskId }}'
  - Name: waitForDiskStatusInUse
    Action: ACS::WaitFor
    Description:
      en: Wait until the cloud disk status changes to In use.
      zh-cn: Wait until the cloud disk status changes to In use.
    Properties:
      Service: ECS
      API: DescribeDisks
      Parameters:
        DiskIds:
          - '{{ createDiskBySnapshot.diskId }}'
      PropertySelector: Disks.Disk[].Status
      DesiredValues:
        - In_use
    Retries: 15
    DelayType: Constant
    Delay: 1
  - Name: mountDisk
    Action: ACS::ECS::RunCommand
    Description:
      en: Mount the cloud disk in the ECS instance.
      zh-cn: Mount the cloud disk in the ECS instance.
    Properties:
      commandType: RunShellScript
      workingDir: '{{ workingDir }}'
      instanceId: '{{ instanceId }}'
      regionId: '{{ regionId }}'
      commandContent: |
        echo "View disks and partitions"
        fdisk -l
        file_system_by_oos=`blkid | tail -n 1 | awk -F : '{print $1}'`
        file_system_type=`blkid | tail -n 1 | awk '{print $4}' | awk -F \" '{print $2}'`
        echo "File system type: ${file_system_type}"
        if [ ${file_system_type} == "xfs" ]; then 
            echo "Modify the UUID of the xfs file system"
            xfs_repair -L ${file_system_by_oos}
            xfs_admin -U generate ${file_system_by_oos}
        else
            echo "Modify the UUID of the ext2, ext3, or ext4 file system"
            e2fsck -y -f ${file_system_by_oos}
            uuidgen | xargs tune2fs ${file_system_by_oos} -U
        fi
        blkid
        echo "Configure the /etc/fstab file and mount the partition"
        cp /etc/fstab /etc/fstab.bakbyoos -n
        mkdir -p /mntbyoos
        echo `blkid ${file_system_by_oos} | awk '{print $2}' | sed 's/\"//g'` /mntbyoos ${file_system_type} defaults 0 0 >> /etc/fstab
        cat /etc/fstab
        mount ${file_system_by_oos}
        echo "View the results"
        df -h
      windowsPasswordName: ''
      enableParameter: false
      parameters: {}
      timeout: 600
      username: ''
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
  - Name: whetherRetainTempDisk
    Action: ACS::Choice
    Description:
      en: Choose the next task based on the retainTempDisk parameter.
      zh-cn: Choose the next task based on whether to retain the temporary cloud disk.
    Properties:
      DefaultTask: waitForUserRestoreData
      Choices:
        - When:
            Fn::Equals:
              - true
              - '{{ retainTempDisk }}'
          NextTask: ACS::END
  - Name: waitForUserRestoreData
    Action: ACS::Pause
    Description:
      en: Wait for the user to manually restore the required data.
      zh-cn: Wait for the user to manually restore the required data.
  - Name: unmountDisk
    Action: ACS::ECS::RunCommand
    Description:
      en: Unmount the cloud disk in the ECS instance.
      zh-cn: Unmount the cloud disk in the ECS instance.
    Properties:
      commandType: RunShellScript
      workingDir: '{{ workingDir }}'
      instanceId: '{{ instanceId }}'
      regionId: '{{ regionId }}'
      commandContent: |
        echo "View partitions"
        df -h
        echo "Unmount the temporary partition and modify the /etc/fstab file"
        file_system_by_oos=`df -h | grep /mntbyoos | awk '{print $1}'`
        umount ${file_system_by_oos}
        sed -i '/\/mntbyoos/d' /etc/fstab
        rm -rf /mntbyoos
        echo "View the results"
        cat /etc/fstab
        df -h
      windowsPasswordName: ''
      enableParameter: false
      parameters: {}
      timeout: 600
      username: ''
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
  - Name: detachDisk
    Action: ACS::ExecuteApi
    Description:
      en: Detach the temporary cloud disk from the ECS instance.
      zh-cn: Detach the temporary cloud disk from the ECS instance.
    Properties:
      Service: ECS
      API: DetachDisk
      Parameters:
        InstanceId: '{{ instanceId }}'
        DiskId: '{{ createDiskBySnapshot.diskId }}'
  - Name: waitForDiskStatusAvailable
    Action: ACS::WaitFor
    Description:
      en: Wait until the cloud disk status changes to Available.
      zh-cn: Wait until the cloud disk status changes to Available.
    Properties:
      Service: ECS
      API: DescribeDisks
      Parameters:
        DiskIds:
          - '{{ createDiskBySnapshot.diskId }}'
      PropertySelector: Disks.Disk[].Status
      DesiredValues:
        - Available
    Retries: 15
    DelayType: Constant
    Delay: 1
  - Name: deleteDisk
    Action: ACS::ExecuteApi
    Description:
      en: Release the temporary cloud disk.
      zh-cn: Release the temporary cloud disk.
    Properties:
      Service: ECS
      API: DeleteDisk
      Parameters:
        DiskId: '{{ createDiskBySnapshot.diskId }}'
Outputs:
  mountDiskOutputs:
    Type: List
    Value: '{{ mountDisk.commandOutput }}'
  unmountDiskOutputs:
    Type: List
    Value: '{{ unmountDisk.commandOutput }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - regionId
          - snapshotId
          - instanceId
        Label:
          default:
            zh-cn: Select Instances
            en: Select Instances
      - Parameters:
          - retainTempDisk
          - workingDir
        Label:
          default:
            zh-cn: Configure Parameters
            en: Configure Parameters
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Control Options
            en: Control Options

Instruções

  1. Leia o conteúdo em inglês para compreender O QUE precisa ser comunicado

  2. Escreva o texto em português do Brasil DO ZERO — esqueça a estrutura das frases em inglês

  3. Preserve toda a formatação markdown, blocos de código, links e imagens exatamente como estão

  4. Tags xref (<a data-tag="xref" ...>texto</a>) — preserve a tag INTEIRA com todos os atributos na ordem e caixa originais, traduza APENAS o texto visível entre > e

  5. Aplique todas as regras específicas de idioma rigorosamente

  6. Aplique as regras de stopwords com tolerância zero

  7. Use o modo imperativo em passos numerados e listas de procedimentos

  8. Garanta a consistência terminológica — o mesmo termo deve ter a mesma tradução em todo o documento

  9. Varie os inícios de frase em listas e tabelas — nenhum início deve se repetir mais de 3 vezes

  10. Retorne APENAS o documento markdown em português do Brasil, sem explicações