Skip to content

Commit 53c62f5

Browse files
committed
fix backup file bloat for running VMs
1 parent a671dee commit 53c62f5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

scripts/vm/hypervisor/kvm/nasbackup.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,25 @@ backup_running_vm() {
171171
sleep 5
172172
done
173173

174+
# Use qemu-img convert to sparsify linstor backups which get bloated due to virsh backup-begin.
175+
name="root"
176+
while read -r disk fullpath; do
177+
if [[ "$fullpath" != /dev/drbd/by-res/* ]]; then
178+
continue
179+
fi
180+
volUuid=$(get_linstor_uuid_from_path "$fullpath")
181+
if ! qemu-img convert -O qcow2 "$dest/$name.$volUuid.qcow2" "$dest/$name.$volUuid.qcow2.tmp" >"$logFile" 2> >(cat >&2); then
182+
echo "qemu-img convert failed for $dest/$name.$volUuid.qcow2"
183+
cleanup
184+
exit 1
185+
fi
186+
187+
mv "$dest/$name.$volUuid.qcow2.tmp" "$dest/$name.$volUuid.qcow2"
188+
name="datadisk"
189+
done < <(
190+
virsh -c qemu:///system domblklist "$VM" --details 2>/dev/null | awk '$2=="disk"{print $3, $4}'
191+
)
192+
174193
rm -f $dest/backup.xml
175194
sync
176195

0 commit comments

Comments
 (0)