[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt-users] Snapshots: Where they are stored and how to use them?



On 10/02/2013 09:26 PM, Roland Giesler wrote:
> Firstly I'd like to learn where a snapshot is stored once it has been
> made.  

If you've created external snapshots, then all the files should be under

  /var/lib/libvirt/images/


Here's just a quick test I did on my laptop:

Before snapshot:
================

# List the current block device of your guest
$ virsh domblklist f19oz
Target     Source
----------------------------------------------
vda        /var/lib/libvirt/images/f19oz.dsk


Create an external disk-only snapshot:
======================================

Note, the guest was running when I did the below:

$ virsh snapshot-create-as f19oz snap1 "snap1-desc" --disk-only --atomic
Domain snapshot snap1 created

After snapshot:
===============

# Notice how the current disk image is the new one ending with .snap1

$ virsh domblklist f19oz
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/f19oz.snap1


Optionally:View the entire backing chain of your images:

$ qemu-img info --backing-chain /var/lib/libvirt/images/f19oz.snap1
image: /var/lib/libvirt/images/f19oz.snap1
file format: qcow2
virtual size: 3.0G (3221225472 bytes)
disk size: 196K
cluster_size: 65536
backing file: /var/lib/libvirt/images/f19oz.dsk
backing file format: raw

image: /var/lib/libvirt/images/f19oz.dsk
file format: raw
virtual size: 3.0G (3221225472 bytes)
disk size: 834M


> I understand that the principle is that when changes occur in
> the VM, the difference is written to the snapshot, thus recording the
> differences between the date/time of the snapshot and the current
> value of the VM.  Is that a correct assessment of the process?

True. There are several different flavours of snapshots. These are discussed elsewhere,
writing it here for convenience:


 1) Internal Snapshots, these can be:

     1.1. Internal 'disk snapshot' -- {live/offline}
     1.2. Internal 'system checkpoint' snapshot -- {live}

  With Internal Snapshots, a single qcow2 file holds everything: original & its delta.
  The original file /must/ be a QCOW2 file.

  NOTE: 'system checkpoint' meaning -- it captures VM state and disk state. Where
  VM state indicates: it captures memory and device state (but not "disk" state).


 2) External Snapshots, these can be:

     2.1. External 'disk snapshot' -- {live/offline}. i.e: snapshot of the
          disk is saved in one file, and the delta since the snapshot is
          tracked in a new qcow2 file.

     2.2. External 'system checkpoint' -- {live}. i.e: the guest's
          disk-state will be saved in one file, its RAM & device-state
          will be saved in another new file.

> 
> If that is indeed so, can I take regular snapshots and back then up
> onto external storage to provide a sort of system restore point at
> certain times in the past?

I don't know what you mean by "regular snapshots" here.

However, an example of live backup using libvirt's blockcopy --
http://kashyapc.fedorapeople.org/virt/lc-2012/live-backup-with-blockcopy.txt

> 
> I have scanned the server hard disks for the snapshot images after
> running "sudo virsh snapshot-create Windows /etc/libvirt/snapshot.xml"

I think you created an 'internal' snapshot (defined above) here. Meaning, your Original
and the delta are stored in the single file. So you'll not find snapshot images files
lying around.

Examining the content of your /etc/libvirt/snapshot.xml would be more useful.


> and the system reports a snapshot was taken, yet I cannot find any
> file that contains the snapshot.
> 
> $ sudo virsh snapshot-list Windows
>  Name                 Creation Time             State
> ------------------------------------------------------------
>  Windows              2013-10-02 12:41:06 +0200 running
> 
> What will happen to the snapshot if the host server is restarted?

The snapshot is still preserved.

> 
> Some insight would be greatly appreciated.


PS: This presentation may give you more idea on different snapshots available --
http://kashyapc.fedorapeople.org/virt/lc-2012/lceu-2012-virt-snapshots-kashyap-chamarthy.pdf

And, some examples listed here (slightly old, but should still be valid) --
http://kashyapc.fedorapeople.org/virt/lc-2012/snapshots-illustration.txt

Hope that helps.

-- 
/kashyap


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]