Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
home_server:home_server_setup:kvm [2025-02-08 Sat wk06 11:37] – [Change the Disk Allocated Size] baumkphome_server:home_server_setup:kvm [2025-02-08 Sat wk06 17:11] (current) – [kvm back-up links] baumkp
Line 64: Line 64:
 ---- ----
 =====KVM Backup===== =====KVM Backup=====
-There seems to be main ways to backup a KVM virual machine +There seems to be main ways to backup a KVM virual machine:
-  - Copy the main file(s) while the VM is running +
-    -  Not recommended as file corruption will probably occur as the VM operation may and probably will modify the file during the copy process+
   - Shutdown the VM first and then copy the file.  Start the VM again after the copy is completed.   - Shutdown the VM first and then copy the file.  Start the VM again after the copy is completed.
   - Use virsh backup-begin command to allow live full backup   - Use virsh backup-begin command to allow live full backup
Line 72: Line 70:
     - Create a snapshot of the VM and direct all changes to the snapshot allowing safe backup of main VM file     - Create a snapshot of the VM and direct all changes to the snapshot allowing safe backup of main VM file
     - Active back commit the snapshot and verify back commit worked     - Active back commit the snapshot and verify back commit worked
 +  * Copy the main file(s) while the VM is running 
 +    -  <fc #ff0000>Not recommended</fc>, as file corruption will probably occur as the VM operation may and probably will modify the file during the copy process
 ====KVM Offline Backup==== ====KVM Offline Backup====
 <fc #ff0000>Note this only works on VMs that are shut down</fc> <fc #ff0000>Note this only works on VMs that are shut down</fc>
Line 82: Line 81:
   -''sudo virsh define --file <path-to-xml-file>'' to import (define) a VM from an XML file.   -''sudo virsh define --file <path-to-xml-file>'' to import (define) a VM from an XML file.
  
 +
 +  *[[https://poweradm.com/backup-kvm-virtual-machine/How to Backup a Virtual Machine on KVM?]]
  
 References: References:
   *[[https://ostechnix.com/export-import-kvm-virtual-machines-linux/|How To Export And Import KVM Virtual Machines In Linux]]   *[[https://ostechnix.com/export-import-kvm-virtual-machines-linux/|How To Export And Import KVM Virtual Machines In Linux]]
 ====kvm back-up links==== ====kvm back-up links====
-  *[[https://schh.medium.com/backup-and-restore-kvm-vms-21c049e707c1|Backup and Restore KVM Vms]] +  *[[https://schh.medium.com/backup-and-restore-kvm-vms-21c049e707c1|Backup and Restore KVM VMs]] - Shutdown VM method 
-  *[[https://www.bacula.org/kvm-backup-vm/|Backula Technical Considerations of a KVM Backup Process]]+  *[[https://www.bacula.org/kvm-backup-vm/|Backula Technical Considerations of a KVM Backup Process]] - Shutdown VM method
   *[[https://www.virtkick.com/docs/how-to-perform-a-live-backup-on-your-kvm-virtual-machines.html|Virtkick - How to Perform a Live Backup on your KVM Virtual Machines]]   *[[https://www.virtkick.com/docs/how-to-perform-a-live-backup-on-your-kvm-virtual-machines.html|Virtkick - How to Perform a Live Backup on your KVM Virtual Machines]]
   *[[https://libvirt.org/kbase/live_full_disk_backup.html|Libvirt.org - Efficient live full disk backup]]   *[[https://libvirt.org/kbase/live_full_disk_backup.html|Libvirt.org - Efficient live full disk backup]]
Line 105: Line 106:
   * ''sudo virsh pool-list'' : List storage pools   * ''sudo virsh pool-list'' : List storage pools
     * ''%%sudo virsh vol-list --pool pool-name%%'' : List volumes in ''pool-name''     * ''%%sudo virsh vol-list --pool pool-name%%'' : List volumes in ''pool-name''
 +  * ''sudo virsh undefine domain-name'' : To remove the VM definition
   * virsh : start, shutdown, destroy, reboot, or pause (suspend / resume)   * virsh : start, shutdown, destroy, reboot, or pause (suspend / resume)
     * ''sudo virsh start domain-name'' : To start a virtual machine of domain ''domain-name''     * ''sudo virsh start domain-name'' : To start a virtual machine of domain ''domain-name''
Line 136: Line 138:
 ====Shrink the Disk File==== ====Shrink the Disk File====
   *Locate the QEMU disk file   *Locate the QEMU disk file
-  *Shut down the VM.+  ***Shut down the VM.**
     *Copy the VM file to a back-up: ''cp image.qcow2 image.qcow2_backup''     *Copy the VM file to a back-up: ''cp image.qcow2 image.qcow2_backup''
   *Option #1: Shrink your disk without compression (better performance, larger disk size):   *Option #1: Shrink your disk without compression (better performance, larger disk size):