purge question about https://libvirt.org/kbase/live_full_disk_backup.html

Hello libvirt users: On QNAP platform, this is my outcome from the following step "2. Enumerate the current block device(s) in use, again. Notice that the current disk image in use is the above-created overlay, overlay1.qcow2:" I'm showing both pre- and post-execution from the shell. There's 2 files. Should both files be purged according to the instruction "Now you can safely discard the overlay image"? + virsh domblklist 9c7d2c4d-9c28-44bd-8da9-642a63b25c39 Target Source ------------------------------------------------------------------------------- vda /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1755932401 hda /share/Virtual-Machines/debian-12.10.0-amd64-netinst.iso ls -alF /share/CACHEDEV2_DATA/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1755932401* -rw-r--r-- 1 admin administrators 177602560 2025-08-23 05:02 SHACKLETON1210_00.1755932401 -rw------- 1 admin administrators 40470118400 2025-08-23 03:42 SHACKLETON1210_00.1755932401.1755934525

On Mon, Aug 25, 2025 at 08:37:24 -0400, Philip Bondi wrote:
Hello libvirt users:
On QNAP platform, this is my outcome from the following step "2. Enumerate
Were you unable to use the 'virDomainBackupBegin' API? (virsh backup-begin) ?
the current block device(s) in use, again. Notice that the current disk image in use is the above-created overlay, overlay1.qcow2:" I'm showing both pre- and post-execution from the shell.
There's 2 files. Should both files be purged according to the instruction "Now you can safely discard the overlay image"?
+ virsh domblklist 9c7d2c4d-9c28-44bd-8da9-642a63b25c39 Target Source ------------------------------------------------------------------------------- vda /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1755932401 hda /share/Virtual-Machines/debian-12.10.0-amd64-netinst.iso
ls -alF /share/CACHEDEV2_DATA/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1755932401* -rw-r--r-- 1 admin administrators 177602560 2025-08-23 05:02 SHACKLETON1210_00.1755932401 -rw------- 1 admin administrators 40470118400 2025-08-23 03:42 SHACKLETON1210_00.1755932401.1755934525
Unfortunately you are showing only one output and didn't post the exact steps that lead to this situation. Since deleting files could lead to data loss in certain situations you will need to verify which images are used and which are not. To do that look at the VM xml (virsh dumpxml) and verify which images are in the backing chain of the disk that you've backed up. The chain looks like: <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/rhel7.1484071880'/> <backingStore type='file'> <format type='qcow2'/> <source file='/var/lib/libvirt/images/rhel7.qcow2'/> <backingStore/> </backingStore> <target dev='vdf' bus='virtio'/> </disk> It can have more nested <backingStore> entries. All of the images captured by the XML are *in use* and must not be deleted. In short you should delete only the temporary overlay that you've created via 'virsh snapshot-create-as' and only after it was succesfully merged via blockcommit.

Hello Peter: Thank you for your reply. I've found the page difficult to follow. There's 13 steps listed, but I found the numbering and heading confusing. I've followed 10 of the 13 steps. After following these 10 steps, I'm asking about purge of files. Have I followed the steps incorrectly? 1. (FOLLOWED) Start the guest: 2. (FOLLOWED) Enumerate the disk(s) in use: 3. (FOLLOWED) Begin the backup: 4. (FOLLOWED) Check the job status ("None" means the job has likely completed): 5. (FOLLOWED) Check the completed job status: 6. (FOLLOWED) Now we see the copy of the backup: Full backup with older libvirt versions 1. (considered optional) Start with a guest with a single disk image, base.raw, which is where the live QEMU is pointing at, and recording the guest writes: 2. (considered optional) List the current block device(s) in use: 3. (considered optional) Create the live "external disk snapshot" (or more correctly, "an overlay"): 1. (FOLLOWED) Now, take a backup the original image, base.raw, to a different location using cp or rsync: 2. (FOLLOWED) Enumerate the current block device(s) in use, again. Notice that the current disk image in use is the above-created overlay, overlay1.qcow2: 3. (FOLLOWED) Once the backup of the original image completes, now perform the "active block-commit" to live-merge the contents of overlay1.qcow2 into base.raw and pivot the live QEMU back to the original: 4. (FOLLOWED) After the above operation completes, again list the current block device(s) in use. And notice that the live QEMU is now writing to the original base image: + onlinebackup + repo=SHACKLETON1210 date +%Y-%m-%d_%H-%M-%S ++ date +%Y-%m-%d_%H-%M-%S + LOGDATE=2025-08-26_19-00-24 basename $0 .sh ++ basename /share/CACHEDEV3_DATA/SHACKLETON12-scripts/qnap-backup.sh .sh + LOGFILE=/share/CACHEDEV3_DATA/SHACKLETON12-scripts/log/qnap-backup.2025-08-26_19-00-24.SHACKLETON1210.log + virsh -v 8.6.0 + virsh domblklist acf333b4-0a75-48fd-ba0d-be26ed48b088 Target Source ------------------------------------------------------------------------------- vda /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 hda /share/Virtual-Machines/debian-12.10.0-amd64-netinst.iso + V_RETURN_CODE=0 + printf 'V_RETURN_CODE: %d\n' 0 V_RETURN_CODE: 0 + [[ 0 -ne 0 ]] + virsh backup-begin acf333b4-0a75-48fd-ba0d-be26ed48b088 Backup started + V_RETURN_CODE=0 + printf 'V_RETURN_CODE: %d\n' 0 V_RETURN_CODE: 0 + [[ 0 -ne 0 ]] + true + sleep 30 Error relocating /QVS/usr/lib/libudev.so.1: canonicalize_file_name: symbol not found + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 30438 ms File processed: 3.481 GiB File remaining: 71.519 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 65427 ms File processed: 7.446 GiB File remaining: 67.554 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 95548 ms File processed: 21.457 GiB File remaining: 53.543 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 125589 ms File processed: 25.455 GiB File remaining: 49.545 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 155638 ms File processed: 29.009 GiB File remaining: 45.991 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 185690 ms File processed: 32.445 GiB File remaining: 42.555 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 215727 ms File processed: 36.395 GiB File remaining: 38.605 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 245766 ms File processed: 46.733 GiB File remaining: 28.267 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 275804 ms File processed: 50.947 GiB File remaining: 24.053 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 305847 ms File processed: 64.445 GiB File remaining: 10.555 GiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: Unbounded Operation: Backup Time elapsed: 335933 ms File processed: 74.500 GiB File remaining: 512.000 MiB File total: 75.000 GiB + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: None virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=None + [[ None == \C\o\m\p\l\e\t\e\d ]] + true + sleep 30 + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 Job type: None + virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed --keep-completed Job type: Completed Operation: Backup Time elapsed: 340009 ms File processed: 75.000 GiB File remaining: 0.000 B File total: 75.000 GiB virsh domjobinfo ${VM_DOMAIN_GUID:-} --completed|awk '$1~/Job/{print $3}' ++ virsh domjobinfo acf333b4-0a75-48fd-ba0d-be26ed48b088 --completed ++ awk '$1~/Job/{print $3}' + V_VIRSH_STATUS=Completed + [[ Completed == \C\o\m\p\l\e\t\e\d ]] + break + V_PROCESS_ID=20435 + echo 'PID: 20435' PID: 20435 + cp -p /share/CACHEDEV2_DATA/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.img /share/CACHEDEV2_DATA/Virtual-Machines-local-backup/SHACKLETON1210/SHACKLETON1210_00.img-backup-1 + rclone -v --log-file /share/CACHEDEV3_DATA/SHACKLETON12-scripts/log/qnap-backup.2025-08-26_19-00-24.SHACKLETON1210.log copy /share/CACHEDEV2_DATA/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.img 'anna_onedrive:Virtual-Machines-img-(DO-NOT-ERASE)/SHACKLETON1210/SHACKLETON1210_00.img-backup-1' + V_RETURN_CODE=0 + printf 'V_RETURN_CODE: %d\n' 0 V_RETURN_CODE: 0 + [[ 0 -ne 0 ]] + wait 20435 + V_RETURN_CODE=0 + printf 'V_RETURN_CODE: %d\n' 0 V_RETURN_CODE: 0 + [[ 0 -ne 0 ]] + virsh domblklist acf333b4-0a75-48fd-ba0d-be26ed48b088 Target Source ------------------------------------------------------------------------------- vda /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 hda /share/Virtual-Machines/debian-12.10.0-amd64-netinst.iso + V_RETURN_CODE=0 + printf 'V_RETURN_CODE: %d\n' 0 V_RETURN_CODE: 0 + [[ 0 -ne 0 ]] virsh domblklist ${VM_DOMAIN_GUID:-} | awk '/vda/{print $2}' ++ virsh domblklist acf333b4-0a75-48fd-ba0d-be26ed48b088 ++ awk '/vda/{print $2}' + V_PURGE_IMG=/share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 + virsh blockcommit acf333b4-0a75-48fd-ba0d-be26ed48b088 vda --active --verbose --pivot Block commit: [ 6 %] Block commit: [ 99 %] Block commit: [100 %] Successfully pivoted + V_RETURN_CODE=0 + printf 'V_RETURN_CODE: %d\n' 0 V_RETURN_CODE: 0 + [[ 0 -ne 0 ]] + virsh domblklist acf333b4-0a75-48fd-ba0d-be26ed48b088 Target Source ------------------------------------------------------------------------ vda /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.img hda /share/Virtual-Machines/debian-12.10.0-amd64-netinst.iso + V_RETURN_CODE=0 + printf 'V_RETURN_CODE: %d\n' 0 V_RETURN_CODE: 0 + [[ 0 -ne 0 ]] dirname ${V_PURGE_IMG:-} ++ dirname /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 + ls -alF /share/Virtual-Machines/SHACKLETON1210 total 237749684 drwxrwxrwx 4 admin administrators 20480 2025-08-26 19:00 ./ drwxrwxrwx 8 admin administrators 4096 2025-05-02 06:44 ../ drwxrwxrwx 3 admin administrators 4096 2025-08-26 10:40 .acf333b4-0a75-48fd-ba0d-be26ed48b088.meta/ drwxrwxrwx 2 admin administrators 4096 2025-08-26 10:40 SHACKLETON1210/ -rw-r--r-- 1 admin administrators 203751424 2025-08-26 11:32 SHACKLETON1210_00.1756219420 -rw-r--r-- 1 admin administrators 166920192 2025-08-26 14:18 SHACKLETON1210_00.1756222321 -rw------- 1 admin administrators 40506884096 2025-08-26 12:07 SHACKLETON1210_00.1756222321.1756224117 -rw-r--r-- 1 admin administrators 6684672 2025-08-26 18:26 SHACKLETON1210_00.1756247131 -rw-r--r-- 1 admin administrators 111345664 2025-08-26 21:48 SHACKLETON1210_00.1756247188 -rw------- 1 admin administrators 40511209472 2025-08-26 19:06 SHACKLETON1210_00.1756247188.1756249224 -rw-rw-rw- 1 admin administrators 40508194816 2025-08-26 21:48 SHACKLETON1210_00.img -rw------- 1 admin administrators 40511078400 2025-08-26 17:00 SHACKLETON1210_00.img.1756241663 -rw-rw-rw- 1 admin administrators 40464941056 2025-08-24 00:26 SHACKLETON1210_00.img.2 -rw-rw-rw- 1 admin administrators 40464941056 2025-08-24 00:26 SHACKLETON1210_00.img.3 + ls -alF /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188.1756249224 -rw-r--r-- 1 admin administrators 111345664 2025-08-26 21:48 /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 -rw------- 1 admin administrators 40511209472 2025-08-26 19:06 /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188.1756249224 + [[ 0 -eq 0 ]] + [[ /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 != *img* ]] + rm /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188 /share/Virtual-Machines/SHACKLETON1210/SHACKLETON1210_00.1756247188.1756249224

On Wed, Aug 27, 2025 at 13:04:05 -0000, pjbondi@systemdatabase.com wrote:
Hello Peter:
Thank you for your reply.
I've found the page difficult to follow. There's 13 steps listed, but I found the numbering and heading confusing. I've followed 10 of the 13 steps.
Yes, the numbering was broken due to a mistake in the source document. I've posted a patch to fix it.
After following these 10 steps, I'm asking about purge of files. Have I followed the steps incorrectly?
1. (FOLLOWED) Start the guest: 2. (FOLLOWED) Enumerate the disk(s) in use: 3. (FOLLOWED) Begin the backup: 4. (FOLLOWED) Check the job status ("None" means the job has likely completed): 5. (FOLLOWED) Check the completed job status: 6. (FOLLOWED) Now we see the copy of the backup:
Wait so you follwed the steps bot for the backup with new libvirt and old libvirt? The first set of steps is sufficient if you have a new enough libvirt and the older steps describe just steps to achieve identical result albeit with more complex approach. So if 'virsh backup-begin' works for you, you are supposed to ignore the rest.
Full backup with older libvirt versions 1. (considered optional) Start with a guest with a single disk image, base.raw, which is where the live QEMU is pointing at, and recording the guest writes: 2. (considered optional) List the current block device(s) in use:
This step is there so that you can compare the before and after as you need to make sure to delete the correct file
3. (considered optional) Create the live "external disk snapshot" (or more correctly, "an overlay"):
this is NOT optional if you are doing the "fallback" method for old libvirt versions
1. (FOLLOWED) Now, take a backup the original image, base.raw, to a different location using cp or rsync: 2. (FOLLOWED) Enumerate the current block device(s) in use, again. Notice that the current disk image in use is the above-created overlay, overlay1.qcow2: 3. (FOLLOWED) Once the backup of the original image completes, now perform the "active block-commit" to live-merge the contents of overlay1.qcow2 into base.raw and pivot the live QEMU back to the original: 4. (FOLLOWED) After the above operation completes, again list the current block device(s) in use. And notice that the live QEMU is now writing to the original base image:
And all of this makes no sense after you skip the step that I've replied above. With 'virsh backup' there's nothing to clean up because the only result is the actual backup file as no intermediates were generated. The blockcommit operation ought to be safe but don't delete anything at this point since you skipped the step that creates the extra overlays.

Thx v much, Peter. OK. I will stop after step 6. And conduct backup of files shown in step 6. As step 6 did not indicate rsync nor cp command, I mislead myself into following the last 4 steps starting with "Now, take a backup the original image, base.raw, to a different location using cp or rsync:"
participants (3)
-
Peter Krempa
-
Philip Bondi
-
pjbondi@systemdatabase.com