Changes

Jump to: navigation, search

stoney conductor: VM Backup

782 bytes added, 12:59, 22 October 2013
/* Snapshot */
== Snapshot ==
# Create a snapshot with state:
#* Save the state of VM <code>vm-001</code> to the file <code>vm-001.state</code>(This file can either be created on a RAM-Disk or directly in the retain location. This example however saves the file to a RAM-Disk): <syntaxhighlight lang="bash">virsh save vm-001 /path/to/ram-disk/vm-001.stat</syntaxhighlight>#* After this command, the VMs CPU and memory state is represented by the file <code>/path/to/ram-disk/vm-001.state</code> and the VM <code>vm-001</code> is shut down.
# Move the disk image <code>/path/to/images/vm-001.qcow2</code> to the retain location: <syntaxhighlight lang="bash">mv /path/to/images/vm-001.qcow2 /path/to/retain/vm-001.qcow2</syntaxhighlight>
#* '''Please note:''' The retain directory (<code>/path/to/retain/</code>) '''has to be''' on the same partition as the images directory (<code>/path/to/images/</code>). This will make the <code>mv</code> operation very fast (only renaming the inode). So the downtime (remember the VM <code>vm-001</code> is shut down) is as short as possible.
# Create the new (empty) disk image with the old as backing store file: <codesyntaxhighlight lang="bash">qemu-img create -f qcow2 -b my-/path/to/retain/vm-backup001.qcow2 my-/path/to/images/vm-001.qcow2</codesyntaxhighlight>#* Set correct ownership and permission to the newly created image:#** <codesyntaxhighlight lang="bash">chown root:vm-storage my-/path/to/images/vm-001.qcow2</codesyntaxhighlight>.#** <codesyntaxhighlight lang="bash">chmod 660 my-/path/to/images/vm-001.qcow2</codesyntaxhighlight>.#* Restore the VMs <code>vm-001</code> from its saved state: <codesyntaxhighlight lang="bash">virsh restore my/path/to/ram-disk/vm-001.state</syntaxhighlight>#* '''Please note:''' After this operation we have a consistent backup for the VM <code>vm-001</code>:#** The file <code>/path/to/ram-disk/vm-001.state</code> contains the CPU and memory state of VM <code>vm-001</code> at time T<sub>1</sub>#** The file <code>/path/to/retain/vm-001.qcow2</code> contains the disk state of VM <code>vm-001</code> at time T<sub>1</sub>
== Merge ==
486
edits