KVM backups

perhaps not simpler, but more generic.
i'm thinking of an automated way to exclude disks with a certain name pattern, that i'm using for caches or generated, expendable data.

let's look at the following kvm-definition:

Code:
name: proxy                                                                                                     
ide2: SAN-NFS-ISO:iso/debian-504-i386-netinst.iso,media=cdrom                                                      
vlan0: virtio=DE:AD:BE:EF:CA:FE
[B]bootdisk: [COLOR=Blue][I]virtio0[/I][/COLOR]
[COLOR=Blue][I]virtio0[/I][/COLOR]: SAN-NFS-Disk:96/vm-96-disk-1.raw
virtio1: SAN-NFS-Disk:96/[COLOR=Red][I]cache[/I][/COLOR]-disk.raw[/B]
ostype: l26
memory: 4096
onboot: 1
sockets: 2
cores: 2
description: proxy, virus filter, ad-blocker
i see two approaches (for virtio):

1) exclude all disks, except the bootdisk.
here we install the operating system on the bootdisk device virtio0.
all additional disks are expendable and can be excluded from backup
basically this can be done in two steps:
a) get virtio0 (or whatever):
Code:
grep '^[COLOR=Blue]bootdisk[/COLOR]' 96.conf.orig |cut -d' ' -f 2
b) filter 96.conf.orig to 96.conf:
Code:
grep -v '^virtio' 96.conf.orig >96.conf
grep '^virtio' 96.conf.orig |grep '^[COLOR=Blue]virtio0[/COLOR]: ' >>96.conf
2) exclude disk pattern (cache):
Code:
grep -v '^virtio.*[COLOR=Red]cache[/COLOR]' 96.conf.orig >96.conf
the hook has to react only on qemu backup jobs ($ENV{VMTYPE})
and creates the .orig copies and does the greps.
afterwards the config is restored and the .orig files are removed.