Virtual machine Snapshots ========================== Internal Snapshot (Simplest) ---------------------------- Explanation: - A single QCOW2 file holds everything (original and its delta) - Very useful when you want to move files across machines - The original file *must* be a QCOW2 file - Guest is _paused_ for more than a couple of seconds External Snapshots (Based on QCOW2 overlays) ------------------ Explanation: - Uses QEMU overlays, meaning: everytime a snapshot is taken, the current disk image in use becomes a _read-only_ "backing file" and a new QCOW2 (overlay) disk image file is created to track the changes - Excellent for live backups - Snapshots are created instantaneously Examples -------- Internal snapshots ~~~~~~~~~~~~~~~~~~ (1) List current disk image in use: $ virsh domblklist f20vm (2) Create snapshot: $ virsh snapshot-create-as f20vm snap1 "Clean F20" (3) Query snapshot info: $ virsh snapshot-list f20vm $ qemu-img info /path/to/disk-image/used/by/f20vm (4) List the current disk image in use (note: it's the same device as before) $ virsh domblklist f20vm To revert --------- $ virsh snapshot-revert f20vm snap1 External snapshots ~~~~~~~~~~~~~~~~~~ (1) To check what is the current disk image in use: $ virsh domblklist f20vm Target Source ------------------------------------------------ hda /var/lib/libvirt/images/Fedora-x86_64-20-20140407-sda.qcow2 (2) Create snapshot: $ virsh snapshot-create-as f20vm snap "snap1-desc" --disk-only --atomic Domain snapshot snap created root@yum.repos.d$ virsh domblklist f20vm Target Source ------------------------------------------------ hda /var/lib/libvirt/images/Fedora-x86_64-20-20140407-sda.snap (2.1) List the snapshots $ virsh snapshot-list f20vm (3) Check now the curren disk use: $ virsh domblklist f20vm Target Source ------------------------------------------------ hda /var/lib/libvirt/images/Fedora-x86_64-20-20140407-sda.snap (4) Check the backing chain: $ qemu-img info --backing-chain /var/lib/libvirt/images/Fedora-x86_64-20-20140407-sda.snap image: /var/lib/libvirt/images/Fedora-x86_64-20-20140407-sda.snap file format: qcow2 virtual size: 2.0G (2147483648 bytes) disk size: 196K cluster_size: 65536 backing file: /var/lib/libvirt/images/Fedora-x86_64-20-20140407-sda.qcow2 backing file format: qcow2 Format specific information: compat: 1.1 lazy refcounts: false image: /var/lib/libvirt/images/Fedora-x86_64-20-20140407-sda.qcow2 file format: qcow2 virtual size: 2.0G (2147483648 bytes) disk size: 1.6G cluster_size: 65536 Format specific information: compat: 0.10