I would test the process out on a junk VM first to make sure you have the process down. Doing a step wrong will result in data loss because it’s a reduction operation.
depends on the filesystem of your VM and if you use SCSI+discard etc.
f.i. ext4 doesn’t reuse/discard blocks of removed files, so you’ll end up with a growing disk image file even if it is/was sparse.
you can simply overwrite the unused disk-space with zeros within the guest. a simple dd if=/dev/zero into a temporary file can do that
after that backups already become smaller and a lot faster.
if you still want to resparse the image, that’s possible for RAW images too, but need the zero’d image anyways to work properly…
shutdown your VM, rename the disk image to something like .bak and run this to resparse
qemu-img convert -O raw ./vm-123-disk-1.raw.bak ./vm-123-disk-1.raw
You need to convert the image, then you can move it over.
In the future, you can use qcow2… add the discard option and run fstrim on the regular. It will automatically shrink your images… however it does have a performance cost.