[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Backup](../../index.md) > [Step-by-step guides](../index.md) > Backups > Restoring a VM or BareMetal server from a backup of another VM or BareMetal server

# Restoring a VM or BareMetal server from a backup of another VM or BareMetal server


{% note info %}

You can restore neither a VM backup to a BareMetal server, nor a BareMetal server backup to a VM.

{% endnote %}

If a folder contains multiple VMs or BareMetal servers connected to Cloud Backup, you can restore a VM or BareMetal server from a backup of another VM or BareMetal server, respectively. You may need this, for example, if the source VM or BareMetal server is down.

To avoid errors when recovering from a backup, start by comparing the parameters of the disks and partitions of the backup against those of the [VM](../../../compute/concepts/vm.md) or Yandex BareMetal [server](../../../baremetal/concepts/servers.md). For more information, see [Viewing the parameters of backup disks and partitions](view-disk-layout.md).

{% note info %}

The operating system of the target VM or BareMetal server must be the same as that of the VM or BareMetal server the backup was created from. The boot disk of the target VM or BareMetal server must be at least the size of the boot disk of the source VM or BareMetal server. The target VM or BareMetal server [status](../../../compute/concepts/vm-statuses.md#list-of-statuses) must be `Running`.

{% endnote %}

To restore a VM or BareMetal server from a backup of another VM or BareMetal server:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder containing the backup.
  1. Navigate to **Cloud Backup**.
  1. In the left-hand panel, select ![backups](../../../_assets/console-icons/archive.svg) **Backups**.
  1. Depending on the resource you want to recover from the backup, select the **Virtual machines** or **BareMetal servers** tab.
  1. In the line with the backup to restore the VM or BareMetal server from, click ![image](../../../_assets/console-icons/ellipsis.svg) and select **Restore VM** or **Recover BareMetal server**, respectively. In the window that opens:
  
      1. Select the VM or BareMetal server to restore the backup to. If needed, click **Create** to [create](../index.md#connect-vm) a new VM or to [lease](../../../baremetal/operations/servers/server-lease.md) a new BareMetal server for recovery from a backup.

          If creating a new VM, wait until the VM [connects](../../concepts/vm-connection.md) to Cloud Backup. If leasing a new BareMetal server, [connect](../backup-baremetal/backup-baremetal.md) it to Cloud Backup. Then click ![refresh](../../../_assets/console-icons/arrow-rotate-right.svg) in the backup recovery window for the new VM or BareMetal server to show up in the list.
  
      1. (Only for VMs) To avoid a conflict between the restored and the source VM, enable **Delete the outdated VM**.

          If this option is not selected, after the recovery the source VM you created the backup from will become outdated. To continue creating backups of this VM, [refresh](../refresh-connection.md) its connection to Cloud Backup.
      1. Click **Restore**.

- CLI {#cli}

  1. If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  1. 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.

  1. View the description of the CLI command to restore a VM or BareMetal server from a backup:

     ```bash
     yc backup backups recover --help
     ```

  1. Get the IDs of the target VM to restore the backup to and the source VM whose backup you want to use:

      ```bash
      yc compute instance list
      ```
      
      Result:
      
      ```text
      +----------------------+---------+---------------+---------+--------------+-------------+
      |          ID          |  NAME   |    ZONE ID    | STATUS  | EXTERNAL IP  | INTERNAL IP |
      +----------------------+---------+---------------+---------+--------------+-------------+
      | jklp0o9i8012******** | my-vm-1 | ru-central1-b | RUNNING | 51.250.**.** | 192.168.*.* |
      | mnoa5s6d8345******** | my-vm-2 | ru-central1-b | RUNNING | 84.201.**.** | 192.168.*.* |
      +----------------------+---------+---------------+---------+--------------+-------------+
      ```

      To get the BareMetal server IDs, select **BareMetal** from the list of services of the relevant [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) in the [management console](https://console.yandex.cloud). The IDs are specified in the server list in the **ID** field.

  1. Get the ID of the backup of the source VM or BareMetal server:

     ```bash
     yc backup backups list \
       --instance-id <source_VM_or_BareMetal_server_ID>
     ```

     Where `--instance-id` is the ID of the source VM or BareMetal server whose backup you want to use.

     Result:

     ```text
     +--------------------------------------+--------------------------------------+----------------------+--------------------------------------+----------------------+------+------------------+--------+---------------------+
     |                  ID                  |              ARCHIVE ID              | COMPUTE INSTANCE ID  |             RESOURCE ID              |      POLICY ID       | TYPE |      DISKS       |  SIZE  |     CREATED AT      |
     +--------------------------------------+--------------------------------------+----------------------+--------------------------------------+----------------------+------+------------------+--------+---------------------+
     | 9cba836d-869c-41d2-8f25-0dac******** | 8a5b6d59-f7ce-0cb9-6cbf-151c******** | epdhmn8mdqmt******** | 7AF6A532-D1DC-4945-9D0C-E101******** | cdgiqu6ouch3******** | FULL | Disk 1 (13.0 GB) | 1.4 GB | 2023-07-11 05:10:09 |
     | 05e964ca-6a8f-481a-b83e-44c5******** | 8a5b6d59-f7ce-0cb9-6cbf-151c******** | epdhmn8mdqmt******** | 7AF6A532-D1DC-4945-9D0C-E101******** | cdgiqu6ouch3******** | FULL | Disk 1 (15.0 GB) | 1.4 GB | 2023-07-11 05:00:07 |
     +--------------------------------------+--------------------------------------+----------------------+--------------------------------------+----------------------+------+------------------+--------+---------------------+
     ```

  1. Restore your VM or BareMetal server from the backup:

     ```bash
     yc backup backups recover \
       --source-backup-id <backup_ID> \
       --destination-instance-id <source_VM_or_BareMetal_server_ID>
     ```

     Where:

     * `--source-backup-id`: Backup ID.
     * `--destination-instance-id`: ID of the target VM or BareMetal server to restore the backup to.

     Result:

     ```text
     ...1s...6s...11s ... 9m4s...9m9s...done (9m9s)
     ```

     For more information about the command, see the [CLI reference](../../../cli/cli-ref/backup/cli-ref/backup/recover.md).

- API {#api}

  Use the [startRecovery](../../backup/api-ref/Backup/startRecovery.md) REST API method for the [Backup](../../backup/api-ref/Backup/index.md) resource or the [BackupService/StartRecovery](../../backup/api-ref/grpc/Backup/startRecovery.md) gRPC API call.

{% endlist %}

{% note info %}

If you are using [LVM](https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)) to manage the disk space of the protected resource, learn [how to restore](../../concepts/backup.md#lvm) resources with LVM in Cloud Backup.

{% endnote %}

Following recovery from a backup, the source VM (unless the **Delete the outdated VM** option was enabled in the management console during the backup) or BareMetal server the backup was created from will become obsolete. To be able to create new backups of the source VM or BareMetal server, refresh their connection to Cloud Backup. For more information, see these guides: [Reconnecting a VM to Cloud Backup](../refresh-connection.md) and [Reconnecting a Yandex BareMetal server to Cloud Backup](../backup-baremetal/refresh-connection.md).

{% note warning %}

After you recover a BareMetal server from another server’s backup, you may lose network access to the target server. This is because the network settings recovered from the backup, namely the network interface MAC addresses, were taken from the source server.

To restore the network on the target VM, update the MAC addresses in the server's network interface settings using the KVM console. You can get current MAC addresses in the server OS using the `ip a` command or in the [management console](https://console.yandex.cloud) on the server information page under **Network interfaces**. For more information on setting up network interfaces in a particular OS, see the relevant OS guides.

{% endnote %}

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

* [Delete backup](delete.md)