Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


What's the safest way for backup and restore external snapshot using virsh libvirtd
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

What's the safest way for backup and restore external snapshot using virsh libvirtd

Dears,

I've followed the following steps in order to get a snapshot of a running VM on my KVM, but actually i'm not sure if that the correct way or no :

/usr/bin/virsh snapshot-create-as \
--domain VM_NAME SNAPSHOT \
--diskspec vda,file=/var/lib/libvirt/images/snapshot.dsk ,snapshot=external \
--disk-only \
--atomic 
  • then i edit the XML configuration in order to change the disk path to the original :

    virsh edit VM_NAME

replace:
/var/lib/libvirt/images/snapshot.dsk
with
/var/lib/libvirt/images/VM.dsk

  • I delete the created snapshot:

/usr/bin/virsh snapshot-delete VM_NAME SNAPSHOT --metadata

  • then i get a copy from the block disk:
/usr/bin/virsh -q blockcopy VM_NAME vda /backup/block.dsk --wait --verbose -
-shallow --pivot
  • then :

/usr/bin/virsh blockcommit VM_NAME vda --active --verbose --pivot

  • then i define the VM again using the its dump XML..

Are these steps correct for taking a safe backup for the instance ? although of the outputed files' sizes are small comparing to the original ?

and the most important part now is:

How to restore the snapshot or the block in case if i faced any problems ?
I tried to restore the block before using this command but it formatted the original disk and replaced with the small block that i backed up before which caused the VM to be lost :

# virsh stop VM_NAME

# qemu-img create \
-b /var/lib/libvirt/images/snapshot.dsk \
-f qcow2 \
var/lib/libvirt/images/VM.dsk

# virsh start VM_NAME

Comments

  • BharatBBharatB Member, Patron Provider
    edited March 2018

    lvcreate -s -L{size}{unit} -n {name} {path/to/lvm}

    ^ incase you're using a lvm

    /bin/dd if="{/path/to/lvm}" of="{/path/to/backup.img}"

    ^ you create an image out of the lvm

  • @BharatB said:
    lvcreate -s -L{size}{unit} -n {name} {path/to/lvm}

    ^ incase you're using a lvm

    /bin/dd if="{/path/to/lvm}" of="{/path/to/backup.img}"

    ^ you create an image out of the lvm

    Thanks dear . but i didn't understand the purpose of this commands ?

    Are they for taking the backup or for restoring it ?

  • BharatBBharatB Member, Patron Provider

    For taking a snapshot and creating a img out of it consider it like a backup

Sign In or Register to comment.