How to backup and restore Xenserver
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
Or
# 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
SERVERNAME spfs
TCPSERVERADDRESS tsm.backup.com
ERRORLOGNAME /var/log/dsmerror_spfs.log
Select the system configuration servername using option file
# vi /etc/spir/dsm.opt
SERVERNAME spfs
Step 3. Create the SPFS configuration files
Create the SPFS option file
# vi /etc/spir/spir.opt
MOUNTPOINT /backup
NODENAME spfs
NODEPWDFILE /etc/spir/TSM.PWD
OPTIONFILE /etc/spir/dsm.opt
Create directory to mount SPFS
# mkdir /backup
Step 4. Configure Spectrum Protect policies
Setup policies
SP> DEFINE DOMAIN spfs
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: https://tecadmin.net/backup-running-virtual-machine-in-xenserver/
#!/bin/bash
#
# Written By: Mr Rahul Kumar
# Created date: Jun 14, 2014
# Last Updated: Mar 08, 2017
# Version: 1.2.1
# Visit: https://tecadmin.net/backup-running-virtual-machine-in-xenserver/
#
DATE=`date +%d%b%Y`
XSNAME=`echo $HOSTNAME`
UUIDFILE=/tmp/xen-uuids.txt
NFS_SERVER_IP=”192.168.10.100"
MOUNTPOINT=/archive
### Create mount point
mkdir -p ${MOUNTPOINT}
BACKUPPATH=${MOUNTPOINT}/${XSNAME}/${DATE}
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
do
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}