Educational ICT Virtualisation Specialist

Twitter LinkedIn E-mail
Precedence Technologies Ltd
Technology House, 36a Union Lane
Cambridge, CB4 1QB, United Kingdom
T: +44 (0)8456 446 800 / +44 (0)1223 359900
F: +44 (0)8456 446 899 / +44 (0)1223 359459
E: enquiries@precedence.co.uk
XenServer

Jump To: Support > KB > Backup > XenServer

Backing up XenServer VMs with NetManager Backup Server

Backing up as templates or live VMs

Pre-requisites

  1. Locate the XenServer scripts provided by Precedence as part of a supported XenServer installation. These will tend to be in the XenServer directory in root's home area on the XenServer pool master (for these examples, we assume the pool master is called xenserver01). Ensure that you have the latest version of the backupvm script.
  2. An iSCSI storage repository will have been created using the NetManager backup server as the backend storage. Determine the name of this storage repository (usually Backup).
  3. Decide whether you want to create the backup as a new runnable virtual machine (i.e. can be immediately started up and run from the backup storage) or as a template (i.e. will need to have a new VM created from it).
  4. Decide which VMs to backup. In many cases, it makes more sense to backup the data within the VM using the NetManager backup agent. This is especially true in the case of fileservers. Examples of machines it is a good idea to backup are: Citrix datastore, one of your XenApp servers (if they are not provisioned), printer server, provisioning server database, domain controller.

Doing a manual backup

N.B. These instructions have been updated for version 1.16 of the backupvm script. Please ensure that you have the latest version before starting.

  • Go to command prompt on the pool master
  • Check the current version of the backupvm script:
Reading ~/backupvm.conf
Syntax: backupvm [-altmrpc] [-g #] [-s <sr>] <vm> [<vm> ...]
$Revision: 1.16 $
        -t = save as template
        -m = save as runnable virtual machine
        -r = backup all running machines
        -s = storage repository to backup to
        -l = list VMs to be backed up and exit
        -a = Backup all VMs except those excluded
        -p = add prefix with date and time to output lines
        -g = number of generations to keep (i.e. delete rest)
        -c = clean up older copies (see -g), do not do new backup

If backupvm.conf is present, this will be used if no options given
VMs listed on command line will override those set in backupvm.conf
  • If Revision is not listed or is less than 1.16, please get the latest version from Precedence before continuing
  • Run the backupvm script specifying the backup type (vm or template), storage repository and then a list of VMs. Name with spaces in need to be quoted and all names are case-sensitive. For the first argument, use -m for a live VM and -t for a template. Specify the storage repository with the -s flag. This example will backup dc01 and Print Server to the backup storage called Backup:
[root@xenserver01 ~]# sh XenServer/backupvm -m -s "Backup" dc01 "Print Server"
Taking snapshot of dc01
Copying dc01 to backup storage
Deleting snapshot
Set template as runnable VM
Taking snapshot of Print Server
Copying Print Server to backup storage
Deleting snapshot
Set template as runnable VM

The backups will be created as new virtual machines (or new templates) and will be visible within XenCenter in the same way as any other VMs or templates. The name of the backup will be the name of the original VM with the date of the backup on the end (e.g. DC01 20101213 for a backup of DC01 taken on 13th December 2010). Therefore, old backups can be deleted from within XenCenter using the usual methods.

If the backup has been created as a live VM, you must be very careful not to start up the backup if the original is already running.

Configuring a standard backup regime to a specified storage repository (as a machine or template)

First ensure you have the latest version of the backupvm script as detailed above.

A text file called backupvm.conf in root's home area on the XenServer can contain standard settings. For example:

action="machine"
sr="Backup"
vms="DC01,DC02,DATASTORE,PRINTERS,SIMS,Team,PVS Core,MLS,Exams,Apps,WLB"
generations="2"
  • For action use either machine or template
  • sr is the name of the Storage Repository. If not specified, it will backup to the same Storage Repository the VM is already on
  • generations is the number of copies of a VM to keep (to keep all versions, set to 0 or don't set)
  • vms is a comma-separated, case-sensitive list of VM names
  • Alternatively you can skip the hardwired vms line and specify a class of machines using a backup line. This should contain either running to backup all running VMs or tag: followed by a tag name (e.g. tag:Backup to backup on the basis of VM tags).

If using tags to select which VMs are to be backed up (e.g. backup="tag:Backup"), all VMs that are tagged with the matching name exactly (case-sensitive) will be selected (for example, Backup will be backed up, backup will not). You can also put a list of days of the week (1=Monday) as numbers after a colon following the tag on the VM. For example, a VM with tag Backup:135 will be backed up only on Monday, Wednesday and Friday (assuming that the backupvm script is run nightly). In this way, some VMs can be backed up more frequently than others.

Once created, you can just run the backupvm script by itself to backup all the configured VMs. Alternatively, you can specify a list of VMs on the command line, e.g. backupvm DC01. To check which VMs will be backed up use the -l flag:

[root@xenserver01 ~]# sh XenServer/backupvm  -l
Reading ~/backupvm.conf
DC01
DC02

To cleanup old versions (i.e. use the number of generations configured and delete any older ones), run sh XenServer/backupvm -c

Copy backups to another XenServer not in the same pool

  • Install the scripts on the other XenServer rather than the main pool.
  • Configure the VMs to be backed up in the same way as usual (vms and backup options in backupvm.conf).
  • Set action to copy
  • generations is the number of copies of a VM to keep (to keep all versions, set to 0 or don't set)
  • Set server to IP address of pool master in main pool
  • Specify XenServer logon details for the main pool (probably root) using username and password options
  • sr does not need to be set as it will import into the default Storage Repository on the backup server
  • Finally, you must specify a temporary storage location to be used on filesystem of the backup server with exportdir. Generally this will probably a separate logical drive on the local RAID controller. This should have an ext3 filesystem on it created with mkfs and be automounted in /etc/fstab (exact procedure for doing this is beyond this document as hardware will vary).

Example backupvm.conf:

exportdir="/staging"
server="172.16.9.101"
user="root"
password="rootpassword"
action="copy"
exclude="FILESERVER"
backup="tag:Backup"
generations="2"

Example list of mounts:

/dev/cciss/c0d0p1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
/opt/xensource/packages/iso/XenCenter.iso on /var/xen/xc-install type iso9660 (ro,loop=/dev/loop0)
/dev/cciss/c0d2p1 on /staging type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

Exporting as .xva files to backup storage

  • Mount the backup storage on a given location (could be local storage formatted as ext3) or an NFS export
  • Configure the VMs to be backed up in the same way as usual (vms and backup options in backupvm.conf).
  • Set action to export
  • sr does not need to be set
  • Do not set generations
  • Specify location to export to with exportdir
© Copyright Precedence Technologies 1999-2017
Page last modified on October 08, 2013, at 05:11 PM by sborrill