I have a Xen server dom0 with a number of guests installed and am struggling to find an easy way to manage backups from the dom0 side.
- Guest scripts: Of course I could run backup scripts on each of the guests but wish to avoid that if possible from a management point-of-view. Ideally I would also like to be able to backup disk images themselves which, along with config, could then be restored directly onto another Xen dom0 if required, along with perhaps a file backup of certain directories.
- rsync of /var/lib/libvirt/images: I have tried a simple rsync of the image files in /var/lib/libvirt/images/ with the domains shut down but there is a problem - the disk images try and copy at their full available size (the size they are available to grow to). So this means each image tries to copy at 250Gb rather than the actual around 2.5Gb (e.g. the size shown by ls -l not the size [used] shown by du).
There are a number of solutions and scripts online but these all seem quite old and seem to be based on disks being LVM devices and so found in /dev/virtual/NAME-disk, whereupon they can be copied and then mounted, and then backed up using rsync. This does not appear to be how my system is configured.
I see a could of potential solutions if they're possible (as I mentioned ideally I would like to backup an image file and also do a file-level backup of certain directories on the VM as well so perhaps a combination of these).
- Shrink Image File: Can I copy the image file and then shrink it to it's actual used space? I could then rsync this and delete the temporary file.
- Copy at actual size: Copy the image file somehow at it's actual size and then if needed recreate the size attributes on another dom0?
- Mount Image File: Somehow mount the image file directly? I see there are ways to convert it to an LVM image but not sure if this is the only way (and I'm happy with the use of image files for the normal operation of the domain guests).
Thanks in advance and hope it's clear enough.