From Fedora Project Wiki

Revision as of 01:10, 30 October 2012 by Crobinso (talk | contribs) (Create page)

Description

Backup a VM's disk image while it is running, with zero downtime. For more details, see:

http://fedoraproject.org/wiki/Features/Virt_Live_Snapshots

Setup

Nothing beyond the initial test day setup (basically a function F18 VM).

Warning.png
Disk space requirements
This test requires enough storage to hold 2 VM disk images. Beware if you're doing your testing in a nested VM!
Warning.png
You disk image will be converted to qcow2
After following these steps, the VMs disk image will be in qcow2 format, regardless of the existing format!

How to test

  1. Start your VM, connect to the graphical console with virt-manager. Log in to your guest.
  2. On the host, create a live snapshot of the guest:
     # virsh snapshot-create-as f18 snapshot1 "snapshot for backup" --disk-only --atomic --no-metadata
  1. Your guest is now running off a sparse qcow2 image. Merge the original disk info into the sparse snapshot:
     # virsh blockpull --domain f18 --path /var/lib/libvirt/images/f18.snapshot1
  1. Watch the progress of this operation:
     # virsh blockjob --info f18 /mnt/data/devel/images/f18.snapshot1
     Block Pull: [ 35 %]
     # virsh blockjob --info f18 /mnt/data/devel/images/f18.snapshot1
     Block Pull: [ 39 %]
  1. While this operation is taking place, connect to the guest and touch a create a few files in $HOME
  2. When the job has finished, the above blockjob command will return empty output
  3. Move the original disk image to your backup location
     # mv /var/lib/libvirt/images/f18.img /my/backup/dir
  1. Verify that the guest is still accessible, and all files can be read ('find /' should be sufficient)

If you want to get back to your original VM image name, you can now do:

     # virsh snapshot-create-as f18 snapshot2 "snapshot for backup" --disk-only --atomic --no-metadata --diskspec vda,file=/var/lib/libvirt/images/f18.img

Then continue with the above steps to merge your changes in the original image, and delete the intermediate f18.snapshot. Your disk f18.img will still be converted to qcow2 however (but that's a good thing!)



Guest is now entirely using f18.snapshot-pt1

  1. yes, 'mv'

mv /mnt/data/devel/images/f18.img /my/backup/location

Expected Results

The following must be true to consider this a successful test run. Be brief ... but explicit.

  1. Step #1 completes without error
  2. The system boots into runlevel 5
  3. Program completes wth exit code 0