[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Backup](../../index.md) > [Step-by-step guides](../index.md) > External resources in Cloud Backup > Connecting an external resource

# Connecting a VM or server from outside Yandex Cloud to Cloud Backup

With Yandex Cloud Backup, you can back up and recover virtual machines and servers located within your own infrastructure or that of a third-party provider.

To [connect](../../concepts/vm-connection/external-resources.md) an external VM or server to Cloud Backup, the resource must be running one of the [supported operating systems](../../concepts/vm-connection/external-resources.md#supported-oss).

For the proper [Cloud Backup agent](../../concepts/agent.md) operation, the VM must meet the [minimum requirements](../../concepts/vm-connection/index.md#requirements).

To connect an external VM or server running a Linux Ubuntu OS to Cloud Backup:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder where you want to connect your external resource to Cloud Backup.
  1. Navigate to **Cloud Backup**.
  1. In the left-hand panel, select ![resources](../../../_assets/console-icons/server.svg) **Connected resources**.
  1. In the top-right corner, click ![image](../../../_assets/console-icons/plug-connection.svg) **Connect external resource**.
  1. In the **Connect external resource** window that opens:

      1. In the **Resource type** field, select the type of the external resource you want to connect: **External virtual machine** or **External server**.
      1. In the **Backup policies** field, select one or more [backup policies](../../concepts/policy.md) to automatically apply to the external resource after installing the agent. You can also [associate](../policy-vm/attach-and-detach-vm.md) these policies later.
      1. Under **Command to install the Cloud Backup agent**, copy the command for installing the Cloud Backup agent on an external resource.

  1. Connect to the external VM or server and run the command you copied with administrator privileges.

      Result:

      ```text
      ...
      Fetched instance id from file: cdgd246kiae3********
      fetched registration token: 802C-AE...
      installing agent with rain https://ru01-cloud.cyberprotect.ru (log: /var/log/baas-agent-installer/log.txt)
      Trying to register agent using RegisterAgent...
      Agent registered with id E6B1A5DC-ECE0-****-A9B8-AFD2********
      ```

  1. Make sure the external resource is connected to Cloud Backup. To do this, on the ![resources](../../../_assets/console-icons/server.svg) **Connected resources** page, open the **External virtual machines** or **External servers** tab, depending on your resource type. The list should include the resource you connected.

- Yandex Cloud CLI {#cli}

  1. [Install](../../../cli/quickstart.md#install) and [initialize](../../../cli/quickstart.md#initialize) the Yandex Cloud CLI.

      You can install the Yandex Cloud CLI either directly on your target VM or server or on any other machine.

      The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

      {% note warning %}

      Make sure the [account](../../../iam/concepts/users/accounts.md) you got authenticated under when creating the Yandex Cloud CLI profile has the `backup.user` [role](../../security/index.md#backup-user) or higher. If needed, [assign](../../../iam/operations/roles/grant.md) the required role to your account.

      {% endnote %}

  1. Get the script code for installing the Cloud Backup agent on an external resource. The exact command depends on the type of resource you want to connect:

      {% list tabs group=backup_resource_type %}

      - VM {#vm}

        ```bash
        yc backup agent install-external vm
        ```

        Result:

        ```bash
        sudo apt-get update && sudo apt-get install -y jq gawk curl && curl https://storage.yandexcloud.net/backup-distributions/agent_installer_external_vm.sh | sudo bash -s -- --instance-registration-token="13d1d696-0ea4-****-93a9-f8c5********"
        ```

      - Server {#baremetal-server}

        ```bash
        yc backup agent install-external server
        ```

        Result:

        ```bash
        sudo apt-get update && sudo apt-get install -y jq gawk curl && curl https://storage.yandexcloud.net/backup-distributions/agent_installer_external_server.sh | sudo bash -s -- --instance-registration-token="ed6991f2-f364-****-a08e-75a7********"
        ```

      {% endlist %}

  1. Run the bash script you got in the previous step:

      {% list tabs group=backup_resource_type %}

      - VM {#vm}

        ```bash
        sudo apt-get update && \
          sudo apt-get install -y jq gawk curl && \
          curl https://storage.yandexcloud.net/backup-distributions/agent_installer_external_vm.sh | sudo bash -s -- --instance-registration-token="13d1d696-0ea4-****-93a9-f8c5********"
        ```

      - Server {#baremetal-server}

        ```bash
        sudo apt-get update && \
          sudo apt-get install -y jq gawk curl && \
          curl https://storage.yandexcloud.net/backup-distributions/agent_installer_external_server.sh | sudo bash -s -- --instance-registration-token="ed6991f2-f364-****-a08e-75a7********"
        ```

      {% endlist %}

      Result:

      ```text
      ...
      Fetched instance id from file: cdgd246kiae3********
      fetched registration token: 802C-AE...
      installing agent with rain https://ru01-cloud.cyberprotect.ru (log: /var/log/baas-agent-installer/log.txt)
      Trying to register agent using RegisterAgent...
      Agent registered with id E6B1A5DC-ECE0-****-A9B8-AFD2********
      ```

      Your external resource is now connected to Cloud Backup and has an ID. In the above example, this is `cdgd246kiae3********`.
  1. Make sure the external resource is connected to Cloud Backup by specifying the ID you got in the previous step:

      ```bash
      yc backup vm get <external_resource_ID_in_Cloud_Backup>
      ```

      Result:

      ```text
      compute_instance_id: cdgd246kiae3********
      created_at: "2026-04-24T14:23:06.382900082Z"
      updated_at: "2026-04-29T19:48:22.013489248Z"
      enabled: true
      status: IDLE
      last_backup_time: "2026-04-27T13:07:05Z"
      next_backup_time: "2026-04-29T21:00:00Z"
      resource_id: d1fdd342-0ea8-****-9906-fa6c********
      is_active: true
      init_status: REGISTRED
      metadata: "null"
      type: EXTERNAL_VM
      agent_info:
        current_version: 18.0.38811
      ```

- API {#api}

  1. Get the command for installing the Cloud Backup agent on an external resource. To do this, use the [getAgentInstallCommand](../../backup/api-ref/Setup/getAgentInstallCommand.md) REST API method for the [Setup](../../backup/api-ref/Setup/index.md) resource or the [SetupService/GetAgentInstallCommand](../../backup/api-ref/grpc/Setup/getAgentInstallCommand.md) gRPC API call. In the request parameters, specify the target resource type: `EXTERNAL_VM` or `EXTERNAL_SERVER`.
  1. Connect to the external VM or server and run the command with administrator privileges.
  1. Once the agent is installed, the external resource is automatically registered in Cloud Backup. To get a list of connected resources, use the [list](../../backup/api-ref/Resource/list.md) REST API method for the [Resource](../../backup/api-ref/Resource/index.md) resource or the [ResourceService/List](../../backup/api-ref/grpc/Resource/list.md) gRPC API call.

{% endlist %}

To back up and restore your connected external resource using Cloud Backup, associate that resource with a [backup policy](../../concepts/policy.md). For more information, see [Linking a resource to a backup policy](../policy-vm/attach-and-detach-vm.md).

#### Useful links {#see-also}

* [Connecting VMs and servers from outside Yandex Cloud to Cloud Backup](../../concepts/vm-connection/external-resources.md)
* [Linking a resource to a backup policy](../policy-vm/attach-and-detach-vm.md)
* [Creating a backup of a resource](../backup-vm/create.md)
* [Recovering an external VM or server from a backup](recover.md)