stoney conductor: VM Backup

From stoney cloud
Revision as of 13:49, 22 October 2013 by Pat (Talk | contribs)


Jump to: navigation, search

Overview

This page describes how the VMs and VM-Templates are backed-up inside the stoney cloud.

Basic idea

The main idea to backup a VM or a VM-Template is, to divide the task into three subtasks:

  • Snapshot: Save the machines state (CPU, Memory and Disk)
  • Merge: Merge the Disk-Snapshot with the live-image
  • Retain: Export the snapshot files

A more detailed and technical description for these three sub-processes can be found in the following sub-chapters.

Snapshot

  1. Create a snapshot with state:
    • Save the state of VM vm-001 to the file vm-001.state:
      virsh save vm-001 vm-001.stat
    • After this command, the VMs CPU and memory state is represented by the file vm-001.state and the VM vm-001 is shut down.
  2. Move the disk image /path/to/images/vm-001.qcow2 to the retain location:
    mv /path/to/images/vm-001.qcow2 /path/to/retain/vm-001.qcow2
    • Please note: The retain directory (/path/to/retain/) has to be on the same partition as the images directory (/path/to/images/). This will make the mv operation very fast (only renaming the inode). So the downtime (remember the VM vm-001 is shut down) is as short as possible.
  3. Create the new (empty) disk image with the old as backing store file: qemu-img create -f qcow2 -b my-vm-backup.qcow2 my-vm.qcow2
    • Set correct ownership and permission to the newly created image:
      • chown root:vm-storage my-vm.qcow2.
      • chmod 660 my-vm.qcow2.
    • Restore the VMs state: virsh restore my-vm.state.

Merge

  1. Merge the disk images my-vm.qcow2 and my-vm-snap.qcow2 to a single image: virsh qemu-monitor-command my-vm --hmp "block_stream drive-virtio-disk0".

Retain

State of the art

Next steps