+ All Categories
Home > Documents > XenServer Backup

XenServer Backup

Date post: 21-Oct-2015
Category:
Upload: kumar-abhinav
View: 83 times
Download: 6 times
Share this document with a friend
Description:
XS backup ppt
Popular Tags:
34
Jerome Reid Disaster recovery and automation with XenServer
Transcript
Page 1: XenServer Backup

Jerome Reid

Disaster recovery and automation with XenServer

Page 2: XenServer Backup

Introduction

Agenda

Backup and recovery tools

XenServer CLI basics

Sample Scripts

Page 3: XenServer Backup

Introduction

Agenda

Backup and recovery tools

XenServer CLI basics

Sample Scripts

Introduction

Backup and recovery tools

Page 4: XenServer Backup

Why backup?

• Failure can result in wider impact as a result of workload consolidation

• A properly designed backup plan will minimize downtime

• Comprehensive backup up plan needed for Disaster recovery

Page 5: XenServer Backup

What can be backed up

• Pool configuration database (state.db)

• VM Metadata

• XenServer Control Domain

Page 6: XenServer Backup

Pool db

•Master maintains pool db•The UUIDs of all objects are tracked in the pool db•Slaves take pool db backup

Master

Slaves

Active pool db

Passive snapshot

db RPC

Page 7: XenServer Backup

Vm metadata

•Contained within the pool db•Contains VM information: name, description, uuid•VM configuration: amount of virtual memory, virtual CPU‘s

Page 8: XenServer Backup

XenServer Control Domain

• The privileged Control Domain that runs Xen and the XenServer agent

• The Control Domain software is installed on the primary partition.

Page 9: XenServer Backup

Backup and recovery tools

• Metadata Backup• xe-backup-metadata, xe-restore-metadata

• Also available via the XenServer console (xsconsole)

• Pool db backup• xe pool-dump-database , xe pool-restore-database

• Vm metadata• xe vm-export --metadata, xe vm-import --metadata

• XenServer Control Domain• xe host-backup

Page 10: XenServer Backup

backup-metadata

• When a metadata backup is first taken, a special backup VDI is created on a SR. This VDI stores the following backups:• A full pool-database backup.

• Individual VM metadata backups, partitioned by the SRs in which the VM has disks.

• SR-level metadata which can be used to recreate the SR description when the storage is reattached.

• The metadata backup and restore works at the command-line script level

• Also supported in the menu-driven text console.

Page 11: XenServer Backup

backup-metadata• Metadata backup/restore can also be performed and scehduled via

the XS console:

Page 12: XenServer Backup

backup-metadata

• Metadata backup/restore can be run and scripted via the CLI: xe-backup-metadata,xe-restore-metadata• xe-backup-metadata provides an interface to create the backup VDIs

• xe-backup-metadata -h

• xe-backup-metadata -c -u <sr uuid>

• xe-backup-metadata -d -u <sr uuid>

Page 13: XenServer Backup

Simplifying Disaster Recovery

Shared Storage Shared Storage

Production Site DR Site

Automated backup of VM metadata to SRReplication of SR includes Virtual Disks and VM metadataAttach replicated SRRestore of VM metadata will recreate VMs

1

2

3

4

1

2

3

4

Page 14: XenServer Backup

pool-dump-database

• Downloads a copy of the entire pool db and dumps it into a file on the client

• Only available via the CLI

• xe pool-dump-database • file-name=

• xe pool-restore-database• File-name=

• Can be scripted and saved to a network share. See Citrix article CTX116632

Page 15: XenServer Backup

pool-dump-database

Pool db

xe-toolstack-restart

pool-restore-database Single Host

Pool db backup

Page 16: XenServer Backup

pool-dump-database

Master

Slaves

pool-restore-database

xe-toolstack-restart

Pool db Pool db backup

Page 17: XenServer Backup

vm-export metadata

• xe vm-export• filename=<filename>

• vm=<vm name-label>

• metadata=true

• xe vm-import • filename=<filename>

• metadata=true

• Can be scripted

• Can be saved to network share. Please see Citrix article CTX117258

Page 18: XenServer Backup

host-backup

• xe host-backup • file-name=

• host= <host_selector_value>

• Archives the active partition to a specified file

• xe host-restore • file-name=

• host= <host_selector_value>.

• extracts the archive created by xe host-backup over the host's currently inactive disk partition

Page 19: XenServer Backup

host-backup

• The backup partition can then be made active by booting off the installation CD and choosing the Restore option.

Page 20: XenServer Backup

Introduction

Agenda

Backup and recovery tools

Sample Scripts

Introduction

XenServer CLI basics

Page 21: XenServer Backup

CLI Basics

• The XenServer CLI provides additional functionality over the XenCenter Interface

• New features are often developed in the CLI before being available in the GUI

• CLI enables scripts for automating system administration tasks

Page 22: XenServer Backup

Object model

• The object model and classes are key to understanding the CLI• Host and VM interact with the storage,virtual disk and network objects using connecttor objects

VM

VIF

Network

PIF

HOST

VBD

VDI

SR

PBD

VM Config

Network Config Disk Config

Host Config

Page 23: XenServer Backup

Object model

VM

VIF

Network

Page 24: XenServer Backup

CLI Basics

• Basic Syntax• xe <command-name> <argument=value> <argument=value>

• Object commands• xe <class>-<TAB>

• Where class can be: bond,console,host,network, patch, pbd, pif, pool,sr, task, template, vbd, vdi, vif, vlan, vm

• Object List commands• xe <class>list-<TAB>

• xe vm-list

• Object Param commands• xe <class>-param-<TAB>

• xe vm-param-list, vm-param-set, vm-param-get,vm-param-clear

Page 25: XenServer Backup

CLI Basics

• Filtering• vm-list HVM-boot-policy="BIOS order" power-state=halted

• Parameterization• xe vm-list params=name-label

• Parameterization and filtering can be combined• xe vm-list HVM-boot-policy="BIOS order" power-state=halted params=name-label

• Minimal Output• xe vm-list HVM-boot-policy="BIOS order" power-state=halted params=name-label --minimal

Page 26: XenServer Backup

Introduction

Agenda

Backup and recovery tools

XenServer CLI basics

Sample Scripts

Introduction

Sample Scripts

Page 27: XenServer Backup

Sample Scripts

• List all loaded CD and set to empty

• Pool-dump database script

• Modify a VIF parameter on all VM's

• VLAN creation

Page 28: XenServer Backup

List all loaded CD and set to empty#!/bin/bash

# this section returns a list of VBD's of type CD, unpluggable false (to avoid listing xentools)# and empty is false to return only loaded CD roms this is all filtering#we are only returning the parameter vm uuid and minimal, the sed utility is used to replace the ,delimitation with spaces#the result is place in the cdlist variablecdlist=`xe vbd-list type=CD unpluggable=false empty=false params=vm-uuid --minimal | sed s/,/" "/g`

#we loop through the cdlist and for each instance we get the name label using the uuid, print it out# and we eject the the CDusing the vm uuidfor vm in $cdlistdoecho $vmvmname=`xe vm-list uuid=$vm params=name-label --minimal`echo "eject CD from $vmname"xe vm-cd-eject uuid="$vm"done

Page 29: XenServer Backup

List all loaded CD and set to empty (Powershell 1)#script to connect to xenserver farm and eject all media$xdsnapin = 'XenServerPSSnapIn'$xsfarmurl = 'http://10.54.76.173'$xsuser = 'root'$xspass = 'citrix‘#Load XS Snapinif(Get-PSSnapin| Where-Object -FilterScript {$_.Name -contains $xdsnapin}){

Write-Host "snapin already loaded"}else{

#load snapin$ret = Add-PSSnapin -Name $xdsnapin -PassThru if(!$ret){

#errorwrite-host "snapin error"break

}else{

Write-Host "snapin added"}

}

Page 30: XenServer Backup

List all loaded CD and set to empty (Powershell 2)#connect to xenserver farm$xs = connect-XenServer -url $xsfarmurl -username $xsuser -password $xspass #comment out -password to force prompt#get list of virtual block devices$vbds = get-XenServer:VBDforeach($vbd in $vbds){

#check to see if its a cd and attachedif ($vbd.type -ieq 'cd' -and $vbd.unpluggable -ieq $False -and $vbd.empty -ieq $False){

#get VM name (there might be a better way)$pht = @{}$pht.Add('opaque_ref',$vbd.VM.ServerOpaqueRef.ToString())$vm = get-xenserver:VM -Properties $phtWrite-Host "removing cd $($vbd.uuid) from vm $($vm.name_label)"$ret = Invoke-XenServer:VBD.eject -besteffort -runasync -vbd $vbd$ret = wait-xenserver:task -Task $ret -besteffort –showprogressif ($ret){

Write-Host "failed to remove cd $($vbd.uuid) from vm $($vm.name_label):$($ret)"}

}}

write-Host 'finished'

Page 31: XenServer Backup

Pool-dump database script# THIS SECTION VERIFIES IF THE LocalDirectoryName HAS NOT BEEN MOUNTED. IF NOT IT WILL MOUNT THE SHARE.

MountName=""MountName=`mount -l | grep LocalDirectoryName`

if [ "$MountName" = "" ]; thenmount -t nfs <NFSSERVERNAME>:/<NFSShareNAME> /<LocalDirectoryName>echo "MOUNT POINT SUCCESSFULL /n"Fi

# THIS SECTION WILL VERIIFY IF THE MOUNT POINT EXISTS BEFORE PERFORMING THE BACKUP OPERATION.

MountTest=""MountTest=`mount -l | grep LocalDirectoryName `

if [ "$MountTest" != "" ]; thenxe pool-dump-database file-name=/ LocalDirectoryName/`date '+XenPoolBackup_%m-%d-%y_%H-%M-%S'`fi

Page 32: XenServer Backup

Modify a VIF parameter on all VM's#!/bin/bash#in this section we list all the vifs,only return the uuid parameter and use the minimal switch to omit the parameter name#we use sed to replace the , delimiter with a space#we place the result in the variable VIFLISTVIFLIST=`xe vif-list params=uuid --minimal | sed s/,/" "/g`

#in this section we loop through VIFLIST# we use param clear to clear the other cconfig parameter and we set the ethtool-tx=off for all the listed vifsfor VIF in $VIFLISTdoecho $VIF xe vif-param-clear uuid=$VIF param-name=other-config xe vif-param-set uuid=$VIF other-config:ethtool-tx="off"done

Page 33: XenServer Backup

VLAN creation#!/bin/bashi=0vlantag=1devname=eth0while [ $i -lt 3 ]donetname=vlan$vlantagnetuuid=`xe network-create name-label=$netname`echo Network UUID $netuuidpifuuid=`xe pif-list device=$devname VLAN=-1 --minimal`echo PIF UUID $pifuuid

vlanuuid=`xe vlan-create network-uuid=$netuuid pif-uuid=$pifuuid vlan=$vlantag`echo Vlan UUID $vlanuuidi=$[$i+1]vlantag=$[$vlantag +1]netuuid=' 'pifuuid=' 'vlanuuid=' '

done

Page 34: XenServer Backup

Continue Your Learning

The following course expands on today's topics and is recommended to support your Citrix solution:

• CXS-200 Implementing Citrix XenServer Enterprise Edition 5.0

Visit www.citrixeducation.com for more information


Recommended