mirror of
https://codeberg.org/hyperreal/techne
synced 2024-11-01 14:23:06 +01:00
81 lines
2.0 KiB
Org Mode
81 lines
2.0 KiB
Org Mode
#+title: QEMU
|
|
#+setupfile: ../org-templates/page.org
|
|
|
|
** Take snapshot of VM
|
|
#+begin_src shell
|
|
sudo virsh domblklist vm1
|
|
|
|
Target Source
|
|
-----------------------------------------------
|
|
vda /var/lib/libvirt/images/vm1.img
|
|
#+end_src
|
|
|
|
#+begin_src shell
|
|
sudo virsh snapshot-create-as \
|
|
--domain vm1 \
|
|
--name guest-state1 \
|
|
--diskspec vda,file=/var/lib/libvirt/images/overlay1.qcow2 \
|
|
--disk-only \
|
|
--atomic \
|
|
--quiesce
|
|
#+end_src
|
|
|
|
Ensure ~qemu-guest-agent~ is installed inside the VM. Otherwise omit the ~--quiesce~ flag, but when you restore the VM it will be as if the system had crashed. Not that big of a deal since the VM's OS should flush required data and maintain consistency of its filesystems.
|
|
|
|
#+begin_src shell
|
|
sudo rsync -avhW --progress /var/lib/libvirt/images/vm1.img /var/lib/libvirt/images/vm1-copy.img
|
|
#+end_src
|
|
|
|
#+begin_src shell
|
|
sudo virsh blockcommit vm1 vda --active --verbose --pivot
|
|
#+end_src
|
|
|
|
** Full disk backup of VM
|
|
Start the guest VM:
|
|
#+begin_src shell
|
|
sudo virsh start vm1
|
|
#+end_src
|
|
|
|
Enumerate the disk(s) in use:
|
|
#+begin_src shell
|
|
sudo virsh domblklist vm1
|
|
|
|
Target Source
|
|
-------------------------------------------------
|
|
vda /var/lib/libvirt/images/vm1.qcow2
|
|
#+end_src
|
|
|
|
Begin the backup:
|
|
#+begin_src shell
|
|
sudo virsh backup-begin vm1
|
|
|
|
Backup started
|
|
#+end_src
|
|
|
|
Check the job status. "None" means the job has likely completed.
|
|
#+begin_src shell
|
|
sudo virsh domjobinfo vm1
|
|
|
|
Job type: None
|
|
#+end_src
|
|
|
|
Check the completed job status:
|
|
#+begin_src shell
|
|
sudo virsh domjobinfo vm1 --completed
|
|
|
|
Job type: Completed
|
|
Operation: Backup
|
|
Time elapsed: 182 ms
|
|
File processed: 39.250 MiB
|
|
File remaining: 0.000 B
|
|
File total: 39.250 MiB
|
|
#+end_src
|
|
|
|
Now we see the copy of the backup:
|
|
#+begin_src shell
|
|
sudo ls -lash /var/lib/libvirt/images/vm1.qcow2*
|
|
|
|
15M -rw-r--r--. 1 qemu qemu 15M May 10 12:22 vm1.qcow2
|
|
21M -rw-------. 1 root root 21M May 10 12:23 vm1.qcow2.1620642185
|
|
#+end_src
|