12.2. Backing Up and Restoring Virtual Machines Using the Backup and Restore API
12.2.1. The Backup and Restore API
The backup and restore API is a collection of functions that allows you to perform full or file-level backup and restoration of virtual machines. The API combines several components of Red Hat Virtualization, such as live snapshots and the REST API, to create and work with temporary volumes that can be attached to a virtual machine containing backup software provided by an independent software provider.
For supported third-party backup vendors, consult the Red Hat Virtualization Ecosystem.
12.2.2. Backing Up a Virtual Machine
Use the backup and restore API to back up a virtual machine. This procedure assumes you have two virtual machines: the virtual machine to back up, and a virtual machine on which the software for managing the backup is installed.
Backing Up a Virtual Machine
Using the REST API, create a snapshot of the virtual machine to back up:
POST /api/vms/11111111-1111-1111-1111-111111111111/snapshots/ HTTP/1.1 Accept: application/xml Content-type: application/xml <snapshot> <description>BACKUP</description> </snapshot>NoteWhen you take a snapshot of a virtual machine, a copy of the configuration data of the virtual machine as at the time the snapshot was taken is stored in the
dataattribute of theconfigurationattribute ininitializationunder the snapshot.ImportantYou cannot take snapshots of disks that are marked as shareable or that are based on direct LUN disks.
Retrieve the configuration data of the virtual machine from the
dataattribute under the snapshot:GET /api/vms/11111111-1111-1111-1111-111111111111/snapshots/11111111-1111-1111-1111-111111111111 HTTP/1.1 Accept: application/xml Content-type: application/xml
Identify the disk ID and snapshot ID of the snapshot:
GET /api/vms/11111111-1111-1111-1111-111111111111/snapshots/11111111-1111-1111-1111-111111111111/disks HTTP/1.1 Accept: application/xml Content-type: application/xml
Attach the snapshot to the backup virtual machine as an active disk attachment, with the correct interface type (for example, virtio_scsi):
POST /api/vms/22222222-2222-2222-2222-222222222222/diskattachments/ HTTP/1.1 Accept: application/xml Content-type: application/xml <disk_attachment> <active>true</active> <interface>_virtio_scsi_</interface> <disk id="11111111-1111-1111-1111-111111111111"> <snapshot id="11111111-1111-1111-1111-111111111111"/> </disk> </disk_attachment>
- Use the backup software on the backup virtual machine to back up the data on the snapshot disk.
Remove the snapshot disk attachment from the backup virtual machine:
DELETE /api/vms/22222222-2222-2222-2222-222222222222/diskattachments/11111111-1111-1111-1111-111111111111 HTTP/1.1 Accept: application/xml Content-type: application/xml
Optionally, delete the snapshot:
DELETE /api/vms/11111111-1111-1111-1111-111111111111/snapshots/11111111-1111-1111-1111-111111111111 HTTP/1.1 Accept: application/xml Content-type: application/xml
You have backed up the state of a virtual machine at a fixed point in time using backup software installed on a separate virtual machine.
12.2.3. Restoring a Virtual Machine
Restore a virtual machine that has been backed up using the backup and restore API. This procedure assumes you have a backup virtual machine on which the software used to manage the previous backup is installed.
Restoring a Virtual Machine
- In the Administration Portal, create a floating disk on which to restore the backup. See Section 10.6.1, “Creating a Virtual Disk” for details on how to create a floating disk.
Attach the disk to the backup virtual machine:
POST /api/vms/22222222-2222-2222-2222-222222222222/disks/ HTTP/1.1 Accept: application/xml Content-type: application/xml <disk id="11111111-1111-1111-1111-111111111111"> </disk>
- Use the backup software to restore the backup to the disk.
Detach the disk from the backup virtual machine:
DELETE /api/vms/22222222-2222-2222-2222-222222222222/disks/11111111-1111-1111-1111-111111111111 HTTP/1.1 Accept: application/xml Content-type: application/xml <action> <detach>true</detach> </action>
Create a new virtual machine using the configuration data of the virtual machine being restored:
POST /api/vms/ HTTP/1.1 Accept: application/xml Content-type: application/xml <vm> <cluster> <name>cluster_name</name> </cluster> <name>_NAME_</name> ... </vm>Attach the disk to the new virtual machine:
POST /api/vms/33333333-3333-3333-3333-333333333333/disks/ HTTP/1.1 Accept: application/xml Content-type: application/xml <disk id="11111111-1111-1111-1111-111111111111"> </disk>
You have restored a virtual machine using a backup that was created using the backup and restore API.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.