Comments on: How to Backup Running Virtual Machine in XenServer https://tecadmin.net/backup-running-virtual-machine-in-xenserver/ How to guide for System Administrator's and Developers Mon, 10 Jun 2019 15:28:36 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: spictera https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-41278 Mon, 10 Jun 2019 15:28:36 +0000 https://tecadmin.net/?p=5463#comment-41278 Protect your XEN VM with Spectrum Protect using SPFS
=================================================
Mount your Spectrum Protect filespace anywhere on your XEN server

# mount -t spfs /backup

Backup the XEN VM nodes using above example

]]>
By: Andrei https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-5520 Sat, 14 Apr 2018 07:53:32 +0000 https://tecadmin.net/?p=5463#comment-5520 You could also use the script from here https://www.baculasystems.com/products/bacula-enterprise-data-backup-tools/citrix-xenserver-backup-software with Bacula Community Edition for free.

]]>
By: dkjkj https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-4611 Sun, 26 Nov 2017 18:11:50 +0000 https://tecadmin.net/?p=5463#comment-4611 On Xen 7.2 the fix for the
[ ! -d ${BACKUPPATH} ] && echo “No backup directory found”; exit 0
is
[ ! -d ${BACKUPPATH} ] && (echo “No backup directory found”; exit 0)

]]>
By: Bill https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-4548 Sun, 12 Nov 2017 01:12:43 +0000 https://tecadmin.net/?p=5463#comment-4548 I had the same problem. I ended up changing this line to :

if [ ! -d “$MOUNTPOINT” ] ; then echo “Mount point ${MOUNTPOINT} not found, kindly check”; exit 0; fi

A little wordier, but it works on my system. I changed the other ‘if exists’ type statements as well to explicit if’s and it all works as expected.

]]>
By: REVERSEARP https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-4540 Fri, 10 Nov 2017 13:10:41 +0000 https://tecadmin.net/?p=5463#comment-4540 I ran into situations where customers did not have enough bandwidth on their storage hardware to complete a backup in a nightly backup. However they still needed some level of protection in the event of malware or admin error. I modified the backup script to only create snapshots of the running VM, and only keep the last 15 days of snapshots. I changed the SNAPSHOT name variable format so that it would not conflict with their existing backup script, so that it could be used in conjunction to the backup script. Just another layer of protection . I installed it into the crontab using * */4 * * * so that it runs every four hours. I hope some will find this useful

DATE=`date +%F`
XSNAME=`echo $HOSTNAME`
MOUNTPOINT=/xenmnt
UUIDFILE=”/tmp/xen-uuids.txt”
NFS_SERVER_IP=”10.10.20.230″

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

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-$DATE”`

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

done ${UUIDFILE}

while read VMUUID
do

xe snapshot-uninstall uuid=$VMUUID –force

done < ${UUIDFILE}

]]>
By: REVERSEARP https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-4349 Wed, 04 Oct 2017 11:09:55 +0000 https://tecadmin.net/?p=5463#comment-4349 So after some testing – the script will backup any size hard drive or VHD that it has access to. However upon doing a restore of that VHD it will fail. It appears that the VHD has to be less than 2000G. The way I overcame this limitation was to use smaller VHD’s and use LVM in linux or in windows spanned disks. If you absolutely need to use a disk that large, create a new SR via nfs and move the vid
s that SR (via mv or cp from cli). them rename the VHD with a valid GUID keeping the VHD extension. Then you can do a SRscan and then attach the disk to the VM. It is literally the only way to deal with restoring VHD’s of that size

]]>
By: RCD https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-3951 Thu, 13 Jul 2017 08:36:22 +0000 https://tecadmin.net/?p=5463#comment-3951 This is kinda like the blind leading the deaf, but since nobody else answered:

The line

#######GET VBD######
for VBDUUID in $(xe vbd-list vm-uuid=${SNAPUUID} empty=false –minimal | sed “s/,/ /g” );

is what controls which volumes are backed up. You can run it “by hand” to see what exactly is include, for example:

# get a list of the VM UUIDS
xe vm-list

# Show the volues attached to the VM you want to look at
xe vbd-list uuid=(enter the UUID you got from the previous command)

So, yes it can be done, but would take some hacking of the script – particularly to have it deal with different situations for different VM’s

]]>
By: REVERSEARP https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-3724 Sun, 14 May 2017 15:41:11 +0000 https://tecadmin.net/?p=5463#comment-3724 Please find below sample instructions for restoring using my modified backup script. If anyone would like to help automate this that would be greatly appreciated.

Contained in the VM backup set you will find several files, an xva file and a VHD image of the hard drives. The XVA file is the definition and or metadata of the vm itself without the VHD or Hard disk.

Get list of SR
xe sr-list

record the sr-uuid you will be using
example:
uuid ( RO) : 0c67c214-5041-2d9e-14db-2d2b7e92a8a2
name-label ( RW): XENSR1
name-description ( RW): iSCSI SR [10.10.20.221 (iqn.1992-04.com.emc:cx.apm00155221699.b5; LUN 2: APM00155221699: 10240 GB (DGC))]
host ( RO):
type ( RO): lvmoiscsi
content-type ( RO):

Import Metadata of VM
xe vm-import preservce=false filename=hylafax-12Mar2017.xva –force sr-uuid=0c67c214-5041-2d9e-14db-2d2b7e92a8a2

Get uuid of imported vm

[root@xenbl460-1 hylafax]# xe vm-list name-label=hylafax
uuid ( RO) : b2fb074f-b024-6d1d-364c-8ac2c73c90b8
name-label ( RW): hylafax
power-state ( RO): haltedGet list of snapshots of MV

Get list of snapshot of vm

[root@xenbl460-1 hylafax]# xe snapshot-list snapshot-of=b2fb074f-b024-6d1d-364c-8ac2c73c90b8
uuid ( RO) : 002ad76c-c281-5ef8-e1dd-afa637c63822
name-label ( RW): SNAPSHOT-6edb308d-4cb7-e16e-f565-fbe95609ab79-12Mar2017
name-description ( RW):

Destroy Snapshot of VM
[root@xenbl460-1 hylafax]# xe snapshot-destroy uuid=002ad76c-c281-5ef8-e1dd-afa637c63822

get list of VBD for VM
[root@xenbl460-1 hylafax]# xe vbd-list vm-uuid=b2fb074f-b024-6d1d-364c-8ac2c73c90b8
uuid ( RO) : e8c9b02a-f73d-907b-b717-ed19b6d5e751
vm-uuid ( RO): b2fb074f-b024-6d1d-364c-8ac2c73c90b8
vm-name-label ( RO): hylafax
vdi-uuid ( RO): a2eea760-6131-4afa-ac7e-87faec69a818
empty ( RO): false
device ( RO):

uuid ( RO) : 893b1267-d3bf-6520-2416-3e7bbadd61d9
vm-uuid ( RO): b2fb074f-b024-6d1d-364c-8ac2c73c90b8
vm-name-label ( RO): hylafax
vdi-uuid ( RO): 53a07b39-eac0-4e72-b0c0-69702474bd4d
empty ( RO): false
device ( RO):

uuid ( RO) : aae311d1-847a-b67c-056c-fd367136889e
vm-uuid ( RO): b2fb074f-b024-6d1d-364c-8ac2c73c90b8
vm-name-label ( RO): hylafax
vdi-uuid ( RO):
empty ( RO): true
device ( RO):

Get VDI info for each VBD
xe vdi-list uuid=53a07b39-eac0-4e72-b0c0-69702474bd4d
xe vdi-list uuid=a2eea760-6131-4afa-ac7e-87faec69a818

Pay attention to the size of the output

[root@xenbl460-1 hylafax]# xe vdi-list uuid=a2eea760-6131-4afa-ac7e-87faec69a818
uuid ( RO) : a2eea760-6131-4afa-ac7e-87faec69a818
name-label ( RW): hylafax_1
name-description ( RW): hylafax_1
sr-uuid ( RO): 0c67c214-5041-2d9e-14db-2d2b7e92a8a2
virtual-size ( RO): 17179869184
sharable ( RO): false
read-only ( RO): false

Import VDI
Now you will import each vhd file that matches the size of the vdi. if your unsure of the size use the following command as an example

Get VHD file information
[root@xenbl460-1 hylafax]# vhd-util scan -f -p -m *.vhd
vhd=hylafax_0-d9d6c6ff-f862-44ca-afc9-48b29c4b4c31.vhd capacity=5368709120 size=365006336 hidden=0 parent=none
vhd=hylafax_1-d487610b-12dc-4d9a-9981-9a97c33fa74b.vhd capacity=17179869184 size=12214732800 hidden=0 parent=none

Manually match the VHD to the VDI based on size or name label of the filename and or VDI
example: xe vdi-import format=VHD filename=hylafax_0-d9d6c6ff-f862-44ca-afc9-48b29c4b4c31.vhd uuid=53a07b39-eac0-4e72-b0c0-69702474bd4d

Do this for each VDI / VHD

Start VM
xe vm-start uuid=b2fb074f-b024-6d1d-364c-8ac2c73c90b8
or
xe vm-start name-label=hylafax

Repeat this process for each VM

]]>
By: Naviathan https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-3677 Fri, 05 May 2017 18:34:26 +0000 https://tecadmin.net/?p=5463#comment-3677 I’m with Joe…Curious about the answer.

]]>
By: mho https://tecadmin.net/backup-running-virtual-machine-in-xenserver/#comment-3647 Sat, 29 Apr 2017 10:46:18 +0000 https://tecadmin.net/?p=5463#comment-3647 Hi Rahul,

thanks for your quick response.

I will try the script of REVERSEARP, (he uses mount -t nfs).
Ofcourse exiting the script when the Mount point directory is not created makes sense. I see ur goal here. But please have a closer look to this line:

‘[ ! -d ${MOUNTPOINT} ] && echo “No mount point found, kindly check”; exit 0’

I did some tests:

[root@xenhost ~]# false && echo “ok” —> nothing happens
[root@xenhost ~]# true && echo “ok” —> shell outputs “ok” (makes sense)
[root@xenhost ~]# false && echo “ok”; exit 0 –> Shell closes
[root@xenhost ~]# true && echo “ok”; exit 0 –> Shell closes

To my mind this script cant work because you always exit the script no matter the mount point directory exist or not… Sorry, just wanna verify this line. I am just wondering why this script works for you?? Where is my mistake …

]]>