Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Iam managing kvm by libvirt and using qcow2 file format. I can create snapshots of running wm with snapshot-create command, but if I transfer my qcow2 image to another host and define transfered host by virsh define, I cant see snapshots created previously. Is there a way how to transfer snapshots too?

Thanks ;-)

share|improve this question

1 Answer 1

Assuming you have already transferred the images themselves and configured added their definitions to the destination libvirt instance all you need to do is to transfer the snapshot definitions as well. Here's a little script to aid you:

#!/bin/sh

SRC_URL=qemu:///system
SRC_DOMAIN_NAME=test
SRC_DOMAIN_UUID=`virsh -c $SRC_URL domuuid $SRC_DOMAIN_NAME`

DST_URL=qemu+ssh://example.com/system
DST_DOMAIN_NAME=test-clone
DST_DOMAIN_UUID=`virsh -c $DST_URL domuuid $DST_DOMAIN_NAME`

# Dump snapshot definitions
virsh -c $SRC_URL snapshot-list $SRC_DOMAIN_NAME | \
awk '$1 ~ /[[:digit:]]+/ { print $1 }' | \
xargs -I{} -n1 sh -c 'virsh -c "$1" snapshot-dumpxml "$2" "$3" | sed s#$4#$5# > "$2-$3.xml"' -- \
$SRC_URL $SRC_DOMAIN_NAME {} $SRC_DOMAIN_UUID $DST_DOMAIN_UUID

# Restore snapshot definitions
find . -type f -name "$SRC_DOMAIN_NAME-*.xml" | \
xargs -n1 echo virsh -c $DST_URL snapshot-create $DST_DOMAIN_NAME 

Just tune the variables to match your hosts and domains.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.