The design given below is obsolete, but the functionality is implemented.
Github PR has the latest details : https://github.com/apache/cloudstack/pull/10140/

--- Obsolete ---

Problem Statement

A. Ability to restore a backup to a new Instance.

Currently Backups are tightly coupled with Instances. Restore can only be done on the same instance from which the backup was taken. If the instance is deleted, backup is not usable and restoring the full backup or individual volumes lead to random exceptions.

This limitation is mostly because of how CloudStacks Backup and Recovery framework code is written. Backup providers usually don’t care if restore is being done to the same VM from which the backup was taken. So there is an opportunity to enhance the BnR framework so that user can create a new Instance and restore from a backup is done on that instance. This will also be useful in cases where the original instance is expunged or unmanaged but the backup is still present.

Support for Dummy, NAS and Veeam Backup Providers will be provided for this feature.

Design

Metadata

When restoring a backup to a new instance, or restoring an expunged instance, the user might want to reuse the state and configuration of the original VM. The metadata can be classified into two types

  1. Instance metadata
    1. networks
    2. ip addresses
    3. compute offering
    4. host
    5. template
  2. Volume metadata
    1. uuid
    2. size
    3. type
    4. path
    5. disk offering

Volume’s uuid, size, type and path are already stored in the backups table (backed_volumes : Backup.VolumeInfo). Remaining metadata can be added as well at the time of backup. And then during restore the fields can be auto-populated in the deploy VM form. The user can choose to use different settings or use the auto-populated ones.

API and Schema changes

New Apis

  1. createInstanceFromBackup extends deployVMCmd :

    Parameters

    1. backupId

    Result: A new instance is created with the given config with all data volumes present in the backup.

Schema Changes

  1. New columns in the backups table

    ColumnTypeDescription
    template_idvarchar(40)template 
    computeoffering_uuidvarchar(40)compute offering of the instance
    network_uuidstextlist of attached network uuids
    ip_addressestextlist of ip addresses corresponding to the networks.

    In addition, the backed_volumes column will also store the diskoffering_uuid for each volume.