How to backup and restore Xenserver

Tomas Dalebjörk
3 min readJan 10, 2022

with IBM Spectrum Protect

Protecting Xenserver is easy with IBM Spectrum Protect. Just install the SPFS software, mount where you want to store the backups, setup your retention policy, done!

Step 1. Installing the IBM Spectrum Protect Client software

# rpm -i gsk*.rpm ; rpm -i TIVsm-API64*.rpm


# dpkg -i gsk*.deb; dpgk -i tivsam-api64*.deb

Step 2. Creating Spectrum Protect configuration files

Create the server system configuration file

# vi /opt/tivoli/tsm/client/api/bin64/dsm.sys



ERRORLOGNAME /var/log/dsmerror_spfs.log

Select the system configuration servername using option file

# vi /etc/spir/dsm.opt


Step 3. Create the SPFS configuration files

Create the SPFS option file

# vi /etc/spir/spir.opt




OPTIONFILE /etc/spir/dsm.opt

Create directory to mount SPFS

# mkdir /backup

Step 4. Configure Spectrum Protect policies

Setup policies


SP> DEFINE POLICYSET spfs standard

SP> DEFINE MANAGEMENTCLASS spfs standard 30days

SP> DEFINE COPYGROUP spfs standard 30days RETEXTRA=30 RETONLY=30 VERDEL=nolimit VEREXIST=nolimit DESTINATION=backuppool

SP> ASSIGN DEFMGMT spfs standard 30days

SP> ACTIVATE POLICYSET spfs standard standard

Register node

SP> REGISTER NODE spfs secretpwd DOMAIN=spfs

Save initial password on client

# setpassword /etc/spir/TSM.PWD <<< secretpwd

Step 5. Mount the file system

# mount.spfs /backup

You are now ready to perform manual or scheduled backups

Manually backing up a server

Select the VM guest you want to protect.

Select the Server -> Back Up Server menu

Browse and select your folder where you want to store your backups, enter your filename, and click Save to start the backup process.

To monitor the progress of your backup, or review log files, select the Logs tab

Backing up the hosts and VMs from command line

To backup the pool metadata

# xe pool-dump-database file-name=/backup/db-pool.dmp

To restore the pool metadata

# xe pool-restore-database file-name=/backup/db-pool.dmp dry-run=true

To backup host configurations and sofwares

# xe host-backup host=host file-name=/backup/hostbackup.bkp

Method 1 — Manual Backup of Running VM

This requires that SPFS is mounted with the added option “DATATYPE archive”, as each backup name is unique, and due to this we have selected another path /archive; so this needs to be changed to in spfs.opt file

Following the examples from this site:



# Written By: Mr Rahul Kumar

# Created date: Jun 14, 2014

# Last Updated: Mar 08, 2017

# Version: 1.2.1

# Visit:


DATE=`date +%d%b%Y`





### Create mount point

mkdir -p ${MOUNTPOINT}


mkdir -p ${BACKUPPATH}

[ ! -d ${BACKUPPATH} ] && echo “No backup directory found”; exit 0

# Fetching list UUIDs of all VMs running on XenServer

xe vm-list is-control-domain=false is-a-snapshot=false | grep uuid | cut -d”:” -f2 > ${UUIDFILE}

[ ! -f ${UUIDFILE} ] && echo “No UUID list file found”; exit 0

while read VMUUID


VMNAME=`xe vm-list uuid=$VMUUID | grep name-label | cut -d”:” -f2 | sed ‘s/^ *//g’`

SNAPUUID=`xe vm-snapshot uuid=$VMUUID new-name-label=”SNAPSHOT-$VMUUID-$DATE”`

xe template-param-set is-a-template=false ha-always-run=false uuid=${SNAPUUID}

xe vm-export vm=${SNAPUUID} filename=”$BACKUPPATH/$VMNAME-$DATE.xva”

xe vm-uninstall uuid=${SNAPUUID} force=true

done < ${UUIDFILE}