Discussion:
[libvirt-users] About libvirt domain snapshot problem(for single disk snapshot)
James Iter
2018-03-20 16:17:58 UTC
Permalink
Hi, dear friend.
My guest has two disks, vda and vdb. both are qcow2 local file.
When guest running state.
I want to take the vda snapshot of guest(just vda, no include vdb). but I met libvirt do snapshot for all disks of guest.

About methods for follow:
1、
``` bash
virsh
snapshot-create-as 8x0lbzvS --name sys_disk3 --disk-only --diskspec "vda,snapshot=external"
```
``` result
[***@10k03 ~]# ls -lh /opt/Images/*sys_disk3
-rw-------. 1 qemu qemu 194K 3月 20 23:27 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sys_disk3
-rw-------. 1 qemu qemu 704K 3月 20 23:52 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sys_disk3

```

2、
``` python
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import libvirt
import libvirt_qemu
import json
import sys


name = sys.argv[1]
print name
conn = libvirt.open()
dom = conn.lookupByName(name)

xml = """
<domainsnapshot>
<name>sysdisk_by_xml</name>
<description>By xml</description>
<disks>
<disk name='vda' snapshot='external'>
</disk>
</disks>
</domainsnapshot>
"""

flags = 0
flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY
flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE

ret = dom.snapshotCreateXML(xmlDesc=xml, flags=flags)
```
``` result
[***@10k03 ~]# ls -lh /opt/Images/*sysdisk_by_xml
-rw-------. 1 qemu qemu 194K 3月 20 23:52 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sysdisk_by_xml
-rw-------. 1 qemu qemu 1.2M 3月 21 00:03 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sysdisk_by_xml

```
。


Then, I search by google. see your page(https://www.redhat.com/archives/libvirt-users/2013-June/msg00102.html).

Now, I want to ask you, was you found the way?


--
James Iter
James Iter
2018-03-20 17:10:15 UTC
Permalink
Hi, dear friends.
My guest has two disks, vda and vdb. both are qcow2 local file.
When guest running state.
I want to take the vda snapshot of guest(just vda, no include vdb). but I
met libvirt do snapshot for all disks of guest.

About methods as follow:
1、
``` bash
virsh
snapshot-create-as 8x0lbzvS --name sys_disk3 --disk-only --diskspec
"vda,snapshot=external"
```
``` result

[***@10k03 ~]# ls -lh /opt/Images/*sys_disk3

-rw-------. 1 qemu qemu 194K 3月 20 23:27 /opt/Images/00d76a58-9637-
4402-9739-21afd1246e06.sys_disk3

-rw-------. 1 qemu qemu 704K 3月 20 23:52 /opt/Images/8d582c1c-355a-
4297-9434-2f2f562c77df.sys_disk3
```

2、
``` python

#!/usr/bin/env python

# -*- coding: utf-8 -*-



import libvirt

import libvirt_qemu

import json

import sys



name = sys.argv[1]

print name

conn = libvirt.open()

dom = conn.lookupByName(name)


xml = """

<domainsnapshot>

<name>sysdisk_by_xml</name>

<description>By xml</description>

<disks>

<disk name='vda' snapshot='external'>

</disk>

</disks>

</domainsnapshot>

"""


flags = 0

flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY

flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE


ret = dom.snapshotCreateXML(xmlDesc=xml, flags=flags)
```
``` result

[***@10k03 ~]# ls -lh /opt/Images/*sysdisk_by_xml

-rw-------. 1 qemu qemu 194K 3月 20 23:52 /opt/Images/00d76a58-9637-
4402-9739-21afd1246e06.sysdisk_by_xml

-rw-------. 1 qemu qemu 1.2M 3月 21 00:03 /opt/Images/8d582c1c-355a-
4297-9434-2f2f562c77df.sysdisk_by_xml
```
。


Then, I searched by google. see your page(https://www.redhat.com/
archives/libvirt-users/2013-June/msg00102.html).

Now, I want to ask you, have you found the method?
--
James Iter
James Iter
2018-03-22 15:52:15 UTC
Permalink
My negligence。

--
James Iter


圚 2018幎3月22日 星期四䞋午11:02Dominik Psenner 写道
I believe that Your mail went to the wrong recipient. As far as I'm
concerned it should have been sent to the libvirt-users mailing list,
shouldn't it?
Thank your reply.
I found the method.
Now, I sharing to you.
When create snapshot, just add ’no’ value to the ’snapshot’ option with —diskspec.
``` bash
snapshot-create-as 8x0lbzvS --name sys_disk --disk-only --quiesce --atomic --diskspec "vda,snapshot=external" --diskspec "vdb,snapshot=no"
```
--
James Iter
圚 2018幎3月21日 星期䞉䞋午6:24Dominik Psenner 写道
(shameless plug)
To do automated daily backups of a few machines I wrote a small toolset to get the job done and make it as less a hassle as you can get. The source is on github https://github.com/dpsenner/libvirt-administration-tools/. Use it if you find it useful.
Note that I have yet not tested it with multiple disks but the tool uses the output of `virsh dombklst`. In theory that should snapshot all disks of a guest machine.
Cheers
Post by James Iter
Hi, dear friends.
My guest has two disks, vda and vdb. both are qcow2 local file.
When guest running state.
I want to take the vda snapshot of guest(just vda, no include vdb). but I met libvirt do snapshot for all disks of guest.
1、
``` bash
virsh
snapshot-create-as 8x0lbzvS --name sys_disk3 --disk-only --diskspec "vda,snapshot=external"
```
``` result
-rw-------. 1 qemu qemu 194K 3月 20 23:27 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sys_disk3
-rw-------. 1 qemu qemu 704K 3月 20 23:52 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sys_disk3
```
2、
``` python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import libvirt
import libvirt_qemu
import json
import sys
name = sys.argv[1]
print name
conn = libvirt.open()
dom = conn.lookupByName(name)
xml = """
<domainsnapshot>
<name>sysdisk_by_xml</name>
<description>By xml</description>
<disks>
<disk name='vda' snapshot='external'>
</disk>
</disks>
</domainsnapshot>
"""
flags = 0
flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY
flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
ret = dom.snapshotCreateXML(xmlDesc=xml, flags=flags)
```
``` result
-rw-------. 1 qemu qemu 194K 3月 20 23:52 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sysdisk_by_xml
-rw-------. 1 qemu qemu 1.2M 3月 21 00:03 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sysdisk_by_xml
```
。
Then, I searched by google. see your page(https://www.redhat.com/archives/libvirt-users/2013-June/msg00102.html).
Now, I want to ask you, have you found the method?
--
James Iter
_______________________________________________
libvirt-users mailing list
https://www.redhat.com/mailman/listinfo/libvirt-users
Loading...