User Tools

Site Tools




  • KISS: simple methods are preferred
  • speed of backups/restores
  • consider both complete backups of domUs and incremental backups
  • restore possible to entirely different dom0?
  • Can the domU continue operation while beeing backupped?
  • Makes it sense/is it possible to also snapshot the complete domU (memory, registers) and be able to restore it?

method 0: lvm-snapshots

  • requirements: domU is lvm-based, space for snapshot is free in volumegroup
  • description: full- or incbackups without interrution of the running domU. All files committed/synced there to the filesystem when the snapshot is taken get available for backup. Backup is taken from dom0, backupclient is only there installed.
grep ^disk /etc/xen/vm/                                # get the lv-volume of the domU
lvs /dev/system/lv_domu_benchlvm                               # optional: verify the logical volume of the domU is accessable
lvcreate -s -L 2G -n lv_domu_benchlvm-snap /dev/system/lv_domu_benchlvm # create the snapshot in the volumegroup
kpartx -a /dev/system/lv_domu_benchlvm-snap                    # get the devnodes for mounting
fsck /dev/mapper/system-lv_domu_benchlvm--snap2                # optional: check if fs-structure is ok
mount /dev/mapper/system-lv_domu_benchlvm--snap2 /mnt/tmp      # mount the partition to be backupped
cd /mnt/tmp && tar cf ....                                     # do the actual full- or incbackup now
umount /mnt/tmp
kpartx -d /dev/system/lv_domu_benchlvm-snap                    # free the no longer needed devnodes
lvremove /dev/system/lv_domu_benchlvm-snap                     # and remove the snapshot again

method 1: copy/cloning of lvm-volume

  • requirements: domU is lvm-based, space for snapshot is free in volumegroup, space for copy
  • description: lvm-snapshot can either be blockwise backed up or copied into an other lvm-volume to clone the domU. All that without interruption of the domU. The volume can also be copied over to a different dom0.
lvcreate -s -L 2G -n lv_domu_benchlvm-snap /dev/system/lv_domu_benchlvm # create the snapshot
lvdisplay /dev/system/lv_domu_benchlvm             # how many le does the original volume consist of? here 1792
lvcreate -l 1792 -n lv_domu_benchlvm-copy system   # create a fresh volume of exact same size, or bigger
cat /dev/system/lv_domu_benchlvm-snap >/dev/system/lv_domu_benchlvm-copy # make the copy
lvremove /dev/system/lv_domu_benchlvm-snap         # remove snapshot
kpartx -av /dev/system/lv_domu_benchlvm-copy       # get devnodes of partitions
mount /dev/mapper/system-lv_domu_benchlvm--copy2 /mnt/tmp
for i in /mnt/tmp/etc/sysconfig/network/ifcfg-eth-id-aa*; do mv -v $i "`echo $i|sed -e 's,13,20,'`"; done
                                                   # fix network-devices
kpartx -dv /dev/system/lv_domu_benchlvm-copy       # remove devnodes
cp /etc/xen/vm/ /etc/xen/vm/  # copy xenfile
vi /etc/xen/vm/                       # modify name, macs, lvm-name
vi /etc/hosts                                      # add newly assigned ip/hostname
vi /etc/dhcpd.conf && rcdhcpd restart              # add newly assigned ip/hostname/mac
xm cr /etc/xen/vm/

method 2: usual backupclient in domU

  • requirements: works for all kinds of domU
  • description: Take domUs as usual servers. Requires domU has proper network-connection to backupserver and backupclient installed. Both full and inc-backups possible.

method 3: copy whole diskfile

  • requirements: works for file-based domU
  • description: Shutdown domU, make copy of diskfile, starts up domU.

method 4: mount diskfile

  • requirements: works for file-based domU
  • description: Shutdown domU, mount diskfile on dom0, backsup full or inc, startup domU.
xm shutdown 110                                 # make sure domU is shut down.
grep ^disk /etc/xen/vm/                 # what exactly is the diskfile?
lomount -diskimage /mnt/nfs_domu/domu_bnas -partition 2 /mnt/tmp
cd /mnt/tmp && tar cf ....                      # take the backup in you way..
cd; umount /mnt/tmp; xm cr /etc/xen/vm/ # cleanup & start up domU again.

method 5: dom0 with backupclient

  • requirements: networking among dom0 and the domUs, backupclient on dom0 installed
  • description: dom0 shares one or more directories via nfs, domUs store there what they need backed up (or their whole /), backupclient at dom0 grabs the while tree

method 6: capture whole domU-state

  • requirements: lvm-based domU
  • description: pause domU, save its memory, create diskvolume-snapshot, unpause domU, backup memory-snapshot and disk-snapshot, remove disk-snapshot. Makes sense i.e. with long-running jobs in the domU, will be recovered incl. applications.
  • FIXME test this method. xm save
software/xen/backups.txt ยท Last modified: 2021/03/23 12:22 (external edit)