Changes

Jump to: navigation, search

stoney conductor: VM Backup

543 bytes removed, 12:49, 22 October 2013
/* Snapshot */
#* Save the state of VM <code>vm-001</code> to the file <code>vm-001.state</code>: <syntaxhighlight lang="bash">virsh save vm-001 vm-001.stat</syntaxhighlight>
#* After this command, the VMs CPU and memory state is represented by the file <code>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: <code>qemu-img create -f qcow2 -b my-vm-backup.qcow2 my-vm.qcow2</code>
#* Set correct ownership and permission to the newly created image:
#** <code>chown root:vm-storage my-vm.qcow2</code>.
#** <code>chmod 660 my-vm.qcow2</code>.
#* Restore the VMs state: <code>virsh restore my-vm.state</code>.
# Merge the disk images my-vm.qcow2 and my-vm-snap.qcow2 to a single image: <code>virsh qemu-monitor-command my-vm --hmp "block_stream drive-virtio-disk0"</code>.
# Move the files to the backup location:
#* Move the old disk image to the backup location and add the date as suffix to not overwrite older backups: <code>mv my-vm-backup.qcow2 /path/to/backup/my-vm-backup.qcow2.date</code>
#* Move the state file to the backup location and add the date as suffix to not overwrite older backups: <code>mv my-vm.state /path/to/backup/my-vm.state.date</code>
== Merge ==
486
edits